具有多行和单行的 LinearLayout

发布于 2024-11-26 00:32:55 字数 1946 浏览 3 评论 0原文

我有这样的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_gravity="center" android:cacheColorHint="#0000" 
        android:background="@layout/selectorgreybutton"
        >
    <LinearLayout
            android:orientation="horizontal"
            style="@style/wrap_content"
            android:layout_alignParentLeft="true"
            >
        <TextView android:id="@+id/group_type"  
                android:paddingRight="10dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="17dip" 
                android:singleLine="false"
                />
        <TextView
                android:id="@+id/group_num" 
                android:paddingRight="10dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="17dip"            
                android:layout_toRightOf="@id/group_type"           
                android:singleLine="true"
                android:gravity="center_vertical"
                />
    </LinearLayout>
    <TextView
        android:id="@+id/arrow"
        android:text="&gt;"
        android:textSize="20dp"
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true"
        android:textColor="@color/black"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        style="@style/wrap_content"
        />
</RelativeLayout>

问题是我只能完全显示第一个 TextView 但不能显示 LinearLayout 内的第二个,这个带有点......我想要始终完全显示第二个 TextView,并在 1 或 2 行中自动调整第一个。 有什么想法吗?

I have this layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_gravity="center" android:cacheColorHint="#0000" 
        android:background="@layout/selectorgreybutton"
        >
    <LinearLayout
            android:orientation="horizontal"
            style="@style/wrap_content"
            android:layout_alignParentLeft="true"
            >
        <TextView android:id="@+id/group_type"  
                android:paddingRight="10dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="17dip" 
                android:singleLine="false"
                />
        <TextView
                android:id="@+id/group_num" 
                android:paddingRight="10dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/black"
                android:textSize="17dip"            
                android:layout_toRightOf="@id/group_type"           
                android:singleLine="true"
                android:gravity="center_vertical"
                />
    </LinearLayout>
    <TextView
        android:id="@+id/arrow"
        android:text=">"
        android:textSize="20dp"
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true"
        android:textColor="@color/black"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        style="@style/wrap_content"
        />
</RelativeLayout>

The problem is that I only can display completly the 1st TextView but not the 2nd inside the LinearLayout, this one appears with dots... And I want to display always the 2nd TextView completely, and the 1st one autoadjust in 1 or 2 lines.
Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百善笑为先 2024-12-03 00:32:55

您可以将此

       android:maxWidth="100dip"
      android:inputType="textMultiLine"

属性用于第一个文本视图,剩余宽度将使用第二个文本视图。

you can use

       android:maxWidth="100dip"
      android:inputType="textMultiLine"

this attribute for 1st textview and remaining width will use second textview.

白云不回头 2024-12-03 00:32:55

在第二个文本视图上使用这些 android:layout_weight="1"

On the second textview use these android:layout_weight="1"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文