【发布时间】:2014-04-18 22:07:20
【问题描述】:
我有一个应用程序正在从 json 文件中提取信息:
{
"EVENTS": [
{
"what": " TABLE-QUIZ",
"who": "anyone",
"when": "31st January",
"where": "ABC HELLO"
}
]
}
当我运行应用程序时,有时When 列中的文本在进入第二行时会在较小的屏幕上被截断。如果What 列中的文本太大,它将进入第二行并且不会被截断。为什么When 列没有进入第二行,而What 列在?
这是我正在使用的布局xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/what"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/textlines"
android:gravity="center"
android:textColor="#fff"
android:textSize="12sp" >
</TextView>
<TextView
android:id="@+id/when"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.65"
android:background="@drawable/textlines"
android:gravity="center"
android:textColor="#fff"
android:textSize="12sp" >
</TextView>
<TextView
android:id="@+id/where"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/textlines"
android:gravity="center"
android:textColor="#fff"
android:textSize="12sp" >
</TextView>
<TextView
android:id="@+id/forWho"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/textlines"
android:clickable="true"
android:gravity="center"
android:onClick="onClick"
android:textColor="#fff"
android:textSize="12sp" >
</TextView>
</TableRow>
</TableLayout>
编辑: 如果我添加:
android:minHeight="30dp"
到TextView 然后我可以让它显示这两行,但我希望有一个可以自动工作的解决方案。
【问题讨论】:
-
嗨,豪利!对不起打扰!您介意重新打开4-years-old question。这个问题缺乏的替代答案很少。这些答案值得放心,并且可能对 AOSP 初学者特别有帮助。提前致谢!
标签: android android-layout textview android-tablelayout