android - 我无法设置 TextView layout_height 来包装内容

标签 android layout textview height

这是我的代码:

    <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/

相关文章:

android - 移动主要内容以显示抽屉

java - 用图像包围 JTextPane

JQuery 记住 CSS 布局更改?

android - 我可以在使用 LinkMovementMethod 时禁用 TextView 中的滚动吗?

android - 如何使用支持库字体功能作为 TextView 内容的一部分(使用 spannable)?

android - 将联系人插入 android 2.2 时如何避免重复?

javascript - Phonegap 中适用于 Android 的应用程序图标

java - 正确的布局可根据每种屏幕尺寸灵活设置 JFrame 和 JInternalFrame

android - TextView 未在 Android 的 onResume 中更新

android - Admob 广告未显示在模拟器或手机中