Data Binding for alternative layouts



I have faced with an issue with data binding for different layouts. I have layout file for different orientation. For portrait mode:

<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>
</layout>

and for landspace mode:

<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="match_parent" />

    <FrameLayout
        android:id="@+id/extra_container"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="match_parent" />

</LinearLayout>
</layout>

And when I use it for binding via

ViewBinding binding = DataBindingUtil.setContentView(this,
R.layout.view);

I have no access for extraContainer from current binding.

Possible solution to add the view with same id and check the view class in runtime. Any other solutions ?


Related to : Data Binding for alternative layouts

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .