2

我的列表视图有一个自定义单元格,其中包含 TEXT NUMBER - 工作正常,但是当 TEXT 超过一行时,右手数字也超过一行,这看起来很傻。是否有属性可以解决此问题?

在此处输入图像描述

我的 XML 是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
    <TextView
        android:id="@+id/txtOption"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="7"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />


    <TextView
        android:id="@+id/txtCount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:paddingBottom="5dp"
        android:paddingLeft="25dp"
        android:paddingRight="15dp"
        android:paddingTop="5dp"
        android:text="[21]"
        android:textAppearance="?android:attr/textAppearanceMedium" />


</LinearLayout>
4

1 回答 1

1

好像你layout_weight的意见没有开始。为此,我认为您在定义中缺少android:weightSum="10"定义LinearLayout。此外,您需要将android:layout_width="0dp"两者都设置为TextView.

于 2012-10-29T14:10:49.993 回答