在 RelativeLayout 中并排放置两个视图的格式问题

Format issue placing two views side by side in RelativeLayout

我在一个相对布局中有两个并排的视图。我希望两个视图的格式都像左边的格式 ("Today's Special")。尽管它们不同,但我已经为两个视图分配了相同的属性。

这是我的xml。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="ExtraText">

<RelativeLayout
    android:id="@+id/view_background"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/bg_row_background">

    <ImageView
        android:id="@+id/delete_icon"
        android:layout_width="@dimen/ic_delete"
        android:layout_height="@dimen/ic_delete"
        android:layout_alignParentEnd="true"
        android:layout_centerVertical="true"
        android:layout_marginEnd="@dimen/padd_10"
        android:contentDescription="@string/deleteIcon"
        android:src="@drawable/ic_delete_white_24dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginEnd="@dimen/padd_10"
        android:layout_toStartOf="@id/delete_icon"
        android:text="@string/delete"
        android:textColor="#fff"
        android:textSize="12sp" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/view_foreground"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:padding="@dimen/padd_5">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/ic_delete"
        android:background="@color/description"
        android:textColor="@color/item_name"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/namecat"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/ic_delete"
        android:layout_alignParentEnd="true"
        android:layout_toEndOf="@id/name"
        android:background="@color/description"
        android:paddingStart="@dimen/padd_10"
        android:textColor="@color/item_name"
        android:textSize="12sp" />
</RelativeLayout>
</FrameLayout>

感谢您的帮助。

用 LinearLayout 和 weightsum 替换 FrameLayout 属性

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="2"
    tools:ignore="ExtraText">

    <RelativeLayout
        android:id="@+id/view_background"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="#978c8c">

        <ImageView
            android:id="@+id/delete_icon"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentEnd="true"
            android:layout_centerVertical="true"
            android:src="@drawable/ic_lock" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toStartOf="@id/delete_icon"
            android:text="@string/dummy_button"
            android:textColor="#fff"
            android:textSize="12sp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/view_foreground"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@android:color/white">

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:background="@color/colorAccent"
            android:textColor="@color/colorPrimary"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/namecat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_toEndOf="@id/name"
            android:background="@color/colorAccent"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="12sp" />
    </RelativeLayout>
</LinearLayout>