Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align text in android

Tags:

android

I want to align my text at the bottom left in android.

like image 943
ryan Avatar asked May 01 '10 17:05

ryan


People also ask

How do you right align text on android?

To right align text in TextView in Kotlin Android, set android:textAlignment attribute with the value “viewEnd” in layout file, or programmatically set the textAlignment property of the TextView object with View.

How do I align text in text view?

To align text in TextView at the center vertically and horizontally we need to make use of gravity attribute. Example 1 : You can use center_vertical | center_horizontal value to set the text at the center of the TextView area.

How do I center text in RelativeLayout android?

android:gravity controls the appearance within the TextView. So if you had two lines of text they would be centered within the bounds of the TextView. Try android:layout_centerHorizontal="true" . Notice that this won't work if a RelativeLayout contains an attribute android:gravity="center_horizontal".


1 Answers

I would recommend a Relative layout.

Your view would look like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text aligned bottom left"
        android:layout_alignParentLeft="true"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>
like image 69
Janusz Avatar answered Oct 09 '22 07:10

Janusz