Android 带有省略号的布局,然后是计数器

Android 带有省略号的布局,然后是计数器,android,Android,我是Android新手,请帮我设计以下布局。非常感谢 我想实现一个布局,它显示一个文本,后跟一个计数器。如果文本太长,请显示。。。然后是柜台。如下图所示: 预期布局: 短文本(3)//屏幕宽度足够时 长文本废话…(2)//当屏幕宽度不够时 下面是我的xml。当文本较短时,它通常显示在1以上。当文本较长时,问题是: 1) 文本末尾不显示“…” 2) 计数器(2)未显示在屏幕上 <LinearLayout xmlns:android="http://schemas.android.com/ap

我是Android新手,请帮我设计以下布局。非常感谢

我想实现一个布局,它显示一个文本,后跟一个计数器。如果文本太长,请显示。。。然后是柜台。如下图所示:

预期布局:

短文本(3)//屏幕宽度足够时

长文本废话…(2)//当屏幕宽度不够时

下面是我的xml。当文本较短时,它通常显示在1以上。当文本较长时,问题是: 1) 文本末尾不显示“…” 2) 计数器(2)未显示在屏幕上

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_weight="1" 
    >

    <TextView android:id="@+id/text" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="very long body safbadaf asfasf safasfd"
        android:layout_gravity="left"
        android:paddingLeft="4dp" android:paddingTop="8dp"
        android:paddingRight="4dp" android:paddingBottom="8dp"
        android:textStyle="bold" android:singleLine="true" android:ellipsize="end"/>
    <TextView android:id="@+id/count" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="count"
        android:layout_gravity="center_horizontal"
        android:paddingLeft="4dp" android:paddingTop="8dp"
        android:paddingRight="4dp" android:paddingBottom="8dp"
        android:textStyle="bold" android:singleLine="true" android:layout_weight="1" />
</LinearLayout>


William

为第一个文本视图而不是第二个文本视图设置android:layout_weight=“1”。还为第一个文本视图设置布局宽度=“0”,而不是为第一个文本视图而不是第二个文本视图设置换行内容。还可以为第一个文本视图设置layout_width=“0”,而不是wrap_content

Frieza,谢谢!但是“0”不是layout_width.Frieza的有效值,谢谢!但是“0”不是布局宽度的有效值。