0

I have three TextViews in a LinearLayout. I want the last TextView to appear in a new line (from the left most side) when Text goes out of bound of the screen width.

Below is the Xml Code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/general_padding"
android:gravity="center_vertical">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true">

    <TextView
        android:id="@+id/objectNameTv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Will Smith "
        android:singleLine="true"
        android:ellipsize="none"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/orange_app_color" />

    <TextView
        android:id="@+id/postDetailTv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="is now following "
        android:singleLine="true"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/subjectNameTv"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Kia Kool hain Hum"
        android:singleLine="true"
        android:maxLines="2"
        android:scrollHorizontally="false"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/orange_app_color" />

</LinearLayout> </RelativeLayout>

xml layout screen shot

Thanks

  • i don't see the purpose of having nested `LinearLayout` with `RelativeLayout` . To display those text you don't need 3 textviews. you can have a single textview that does the job – Raghunandan Jan 28 '16 at 16:11
  • you can only do this programmatically. – Andrei Jan 28 '16 at 16:30

1 Answers1

0

You can't do this from xml but you could do this programatically using only one TextView. I hope that this post will help you: Different font size of strings in the same TextView

Community
  • 1
  • 1
David Rauca
  • 1,583
  • 1
  • 14
  • 17