Cannot resolve layout with merge tag

Viewed 251

Been back after long to Android Studio. I have started using AndroidX library. I am not able to understand why can't layout with starting with LinearLayout or Merge tags cannot be resolved?

Here's the code where I am importing the layout with <merge/> tag.

 private void init(Context context, @Nullable AttributeSet attrs) {
        View rootView = inflate(context, R.layout.fab_label_view, this);

        mFab = rootView.findViewById(R.id.sd_fab);
        mLabelTextView = rootView.findViewById(R.id.sd_label);
        mLabelCardView = rootView.findViewById(R.id.sd_label_container);

        setFabSize(SIZE_MINI);
        setOrientation(LinearLayout.HORIZONTAL);
        setClipChildren(false);
        setClipToPadding(false);

Here's the layout resource code:

<merge xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.sagar.walkie.ui.fab.FabLabelView">

    <androidx.cardview.widget.CardView
        android:id="@+id/sd_label_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:clickable="true"
        android:focusable="true"
        android:foreground="?attr/selectableItemBackground"
        app:cardCornerRadius="4dp"
        app:cardElevation="1dp"
        app:cardUseCompatPadding="true"
        app:contentPadding="4dp">

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/sd_label"
            style="@style/FabItem.FabLabelStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="A label" />
    </androidx.cardview.widget.CardView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/sd_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|end"
        app:fabSize="mini"
        app:useCompatPadding="true" />

</merge>
0 Answers
Related