I have 2 layouts: one for v19 + and the other for earlier versions. They contain different types with different identifiers. How can I tell the Android DataBinding framework that I want to work with both layouts? It generates views for only one layout (selects randomly).
layout / temp_view.xml:
<layout 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"> <data> <variable name="block" type="ru.temp.model.content.blocks.WebMediaBlock" /> <import type="ru.temp.model.Types.ProviderTypes" /> </data> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:background="@android:color/white"> <ImageView android:id="@+id/provider" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:paddingTop="@dimen/size5" android:src="@{ProviderTypes.fromString(block.provider).getResId()}" /> </FrameLayout> </layout>
layout-v19 / temp_view.xml:
<layout 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"> <data> <variable name="block" type="ru.temp.model.content.blocks.WebMediaBlock" /> <import type="ru.temp.model.Types.ProviderTypes" /> </data> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" tools:background="@android:color/white"> <ru.temp.utils.EmbedView android:id="@+id/media_embed" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ru.temp.structure.static_material.CreditsView android:id="@+id/credits_view" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </FrameLayout> </layout>
Update:
Finally, I found out the root of the problem. I donβt know why, but it does not generate * BindingImpl files when using minSdkVersion 21. If you specify earlier versions, it works as @yigit said
source share