Whenever i use "xyz.setText("blah blah")" the text view expands according to the size of the content.App is crashing constantly.please help (gridlayout=2X2)
<TextView
android:id="@+id/rowzcolz"
android:text="TextView"
android:gravity="fill"
app:layout_rowWeight="1"
android:textAlignment="center"
app:layout_columnWeight="1"/>
<TextView
android:id="@+id/rowzcolo"
android:textAlignment="center"
android:text="TextView"
android:gravity="fill"
app:layout_rowWeight="1"
app:layout_columnWeight="1"/>
<TextView
android:id="@+id/rowocolz"
android:textAlignment="center"
android:text="TextView"
android:gravity="fill"
app:layout_rowWeight="1"
app:layout_columnWeight="1" />
<TextView
android:id="@+id/rowocolo"
android:textAlignment="center"
android:gravity="fill"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:text="TextView"/>
</android.support.v7.widget.GridLayout>
Q: the text view expands according to the size of the content
A: Might occur if you have given the width as
match_parent
orwrap_content
try giving a fixed width and settingmaxLines
to restrict the text. Specify the width and height apart from rowWeight.
Something that might help you to restrict the characters to maximum length called,
android:maxLength="5"
along with ellipsize ".." in the end.
android:ellipsize="end"
And if you want the characters to appear in two lines ,
android:maxLines="2"
And you might have to specify the width of the TextView
for each instead of wrap_content
or match_parent
.
android:layout_width="80dp"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.