To left align the text in this Textview through layout file, set the android:textAlignment attribute for the TextView to “viewStart”, as shown in the following activity_main. xml layout file.
So the gravity attribute specifies how to align the text inside the TextView layout_gravity specifies how to align/layout the TextView element itself.
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.
You should use android:gravity="right"
. layout_gravity
is for the view (EditText) alignment against the container.
You may use android:layout_alignParentRight="true"
to align the EditText's right edge to its parent's right edge. Also, if you really want to use the layout_gravity
or gravity
attributes, check out this article that discusses the proper use of them.
You can jst set property for edit text in property window i.e. Gravity to right or by adding code of lin e in xml file of UI : android:gravity="right"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With