【发布时间】:2013-12-20 18:35:59
【问题描述】:
文本视图未正确显示文本。文本跨越两行,但第二行文本只显示文本的上半部分,就好像文本被水平切成两半一样,尽管使用了height = wrap_content。
xml代码:
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:weightSum="1" >
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="No. of direct Reportees:" />
<EditText
android:id="@+id/direct"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:hint="Eg. 12"
android:inputType="numberDecimal"
android:textAppearance="?android:attr/textAppearanceSmall" >
<requestFocus />
</EditText>
</TableRow>
已解决:
此行为是由于基线对齐。容器具有正确的高度(它是它的两个孩子的最大值),但 Textview 向下移动以与按钮对齐基线。无法更改此行为以保留现有应用程序中的布局。在您的情况下实现此布局的正确方法是在LinearLayout 标签上添加android:baselineAligned="false"。这也将消除TextView上方的额外垂直空间。
【问题讨论】:
标签: android android-layout textview android-tablelayout