0

我有 3 个视图,我想排成一行。这些视图是: TextView 查看 TextView 应该如下所示:

Today --------- 89

行应填充这 2 个 TextView 留下的所有空闲空间。我尝试使用此代码,但行将“89”从屏幕上移出。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/list_mail_header_day"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Today"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/background_seen" />

<View
    android:id="@+id/list_mail_header_line"
    android:layout_width="wrap_content"
    android:layout_height="2dp"
    android:layout_alignParentTop="true"
    android:layout_margin="2dp"
    android:layout_toRightOf="@+id/list_mail_header_day"
    android:background="@color/background_seen" />

<TextView
    android:id="@+id/list_mail_header_counter"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/list_mail_header_line"
    android:text="89"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#000"
    android:textStyle="bold" />

4

1 回答 1

1

尝试将 aLinearLayout与非零布局权重组合:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/list_mail_header_day"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Today"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/background_seen" />

    <View
        android:id="@+id/list_mail_header_line"
        android:layout_width="0dp"
        android:layout_height="2dp"
        android:layout_weight="1"
        android:layout_margin="2dp"
        android:background="@color/background_seen" />

    <TextView
        android:id="@+id/list_mail_header_counter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="89"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#000"
        android:textStyle="bold" />

</LinearLayout>
于 2013-07-22T16:29:28.370 回答