YosiFZ
YosiFZ

Reputation: 7900

TextView align with two lines

I put TextView in a layout with const string. the string is long so i define two lines TextView . the problem is that the second line start from the right instead from the center. how i can to align the TextView to be from the center

        <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_item"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:layout_gravity="center_horizontal" android:lines="2" android:textColor="@color/Red"/>

Upvotes: 1

Views: 3140

Answers (2)

Vinayak Bevinakatti
Vinayak Bevinakatti

Reputation: 40503

adding android:gravity="center" will work

Upvotes: 1

Orkun
Orkun

Reputation: 7238

I think it s the gravity attribute

 <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_item"
        android:gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:layout_gravity="center_horizontal" android:lines="2" android:textColor="@color/Red"/>

Could you try this? Hope it helps.

Upvotes: 6

Related Questions