I have the following Layout which does not work:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:id="@+id/experienceLayout"
android:background="#ffffff"
android:layout_height="match_parent"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="6dp"
android:paddingTop="6dp">
<TextView
android:layout_weight="1"
android:id="@+id/experienceLabel"
android:text="Experience"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_width="wrap_content"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/experienceTextView"
android:text="TextView"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_width="wrap_content"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:fadeScrollbars="false">
</TextView>
</LinearLayout>
This will also make a single line with ellipsise
Use this
Don't use this without fully aware of what output comes
When you use
maxlines = 1
it will some time truncate most of the characters.This is a common problem. Try using the following:
.............. the scrollHorizontally is the "special sauce" that makes it work.
The way it worked for me on multiple devices / APIs was programmatically like this (where tv is your TextView):