Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between viewEnd and textEnd in android:textAlignment

Tags:

android

I was going through documentation of android:textAlignment and it has 7 options few of those are viewEnd/viewStart and textEnd/textStart

I could not understand what is difference in view#### vs text#### using docs from the POV of use cases.If anyone can clarify that in more detail using some examples or use cases?

like image 775
vipin agrahari Avatar asked Apr 21 '17 06:04

vipin agrahari


People also ask

What is text alignment in android?

value class TextAlign. Defines how to align text horizontally. TextAlign controls how text aligns in the space it appears.

How do I change the text on the left side of my android?

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.

How can I center text programmatically in android?

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

How do you justify text on android?

Just to add, if you want center justification, you can do android:layout_gravity="center_horizontal|center" android:gravity="center" .


1 Answers

My observation,

if the textDirection or layoutDirection is ltr then, viewStart/End and textStart/End behaves the same.

But if you change one of the textDirection or layoutDirection to rtl, and now try the view/text start/end, you will visually see the difference.

one of the combination

like image 73
yajnesh Avatar answered Nov 15 '22 05:11

yajnesh