布局不从合并标签中获取属性

Layout not taking properties from merge tag

我有下一个布局:

<RelativeLayout 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:background="@drawable/bg_round_rect_4_melanzane_dark"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:paddingStart="16dp"
    android:paddingTop="8dp"
    android:paddingEnd="16dp"
    android:paddingBottom="8dp">
        <TextView />
        <TextView />
        <EditText />
</RelativeLayout>

我在自定义视图中对其进行充气,例如:

class LabeledEditText : RelativeLayout {

    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

    init {
        inflate(context, R.layout.view_labeled_edit_text, this)
    }
}

一切正常。但是,如果我将 RelativeLayout 更改为 xml 中的合并标签,我的视图将不会获得背景和可聚焦等属性。这就是我改变它的方式:

<merge 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:background="@drawable/bg_round_rect_4_melanzane_dark"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:paddingStart="16dp"
    android:paddingTop="8dp"
    android:paddingEnd="16dp"
    android:paddingBottom="8dp"
    tools:parentTag="android.widget.RelativeLayout">
        <TextView />
        <TextView />
        <EditText />
</merge>

我必须做什么才能在我的自定义视图中从合并标签获取参数到父布局?

布局不会从合并标签中获取属性。