用大小不随内容改变的固定大小的文本视图填充网格布局中的每个槽

Fill each slot in a grid layout with fixed size text views whose size doesn't change with content

每当我使用 "xyz.setText("blah blah")" 文本视图会根据 content.App 的大小展开 constantly.please 帮助 (网格布局=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>

问:文本视图根据内容的大小展开

A: Might occur if you have given the width as match_parent or wrap_content try giving a fixed width and setting maxLines to restrict the text. Specify the width and height apart from rowWeight.

可能会帮助您将字符限制为最大长度的东西已调用,

android:maxLength="5"

连同 ellipsize ".." 最后。

android:ellipsize="end"

而如果你想让字符出现在两行,

android:maxLines="2"

并且您可能必须为每个 TextView 指定 宽度 ,而不是 wrap_contentmatch_parent

android:layout_width="80dp"