这是我的代码:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting"
android:layout_column="1"/>
<EditText
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:id="@+id/editText3" android:layout_column="2"/>
</TableRow>
</TableLayout>
</ScrollView>
在此示例中,只有 2 行文本可见,但行数超过 2 行。如何设置此 TextView 的高度以包裹内容而不是溢出内容?
最佳答案
给 TextView 添加内边距:
android:padding="10dp"
例如:
<TextView
android:layout_width="0dp"
android:layout_weight=".50"
android:layout_height="wrap_content"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting"
android:layout_column="1"
android:padding="10dp"/>
关于android - 我无法设置 TextView layout_height 来包装内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21900687/