How To Hide The Text When Wrapping?
Solution 1:
Finally I find the solution, if the TextView which is the child of GridLayout. I can't set the width to WRAP_CONTECT becacuse it will use the whole row as the width but not the width of the cell. The solution is that set the width to 0dp and set the layout_gravity to fill_horizontal. Also, the width of the gridlayout must be MATCH_PARENT.
<GridLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:columnCount="3"android:orientation="horizontal">
.
.
.
<TextViewandroid:layout_marginLeft="12dp"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_gravity="fill_horizontal"android:text="New Text"android:id="@+id/tvVExample"android:textColor="#496933"android:textStyle="bold"android:textSize="16sp"/>
.
.
.
</GridLayout>
Solution 2:
It seems in many cases the trick was not to setup single="false"
but maxLines="100"
, maybe you can have a try:
<TextView
android:layout_marginLeft="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/tvVExample"
android:textColor="#496933"
android:maxLines="100"
android:textStyle="bold"
android:textSize="16sp"/>
If you are using a LinearLayout and above is not working, you can maybe try adding android:layout_weight="1"
(but layout_width
will have to be set to match_parent
).
Post a Comment for "How To Hide The Text When Wrapping?"