In one project I was working, has 2 layouts for a custom view. For 220 screenWidthDp
has different layout. View ids are same in both layouts. Currently layouts are loaded like this
Configuration config = getResources().getConfiguration();
if ( config.screenWidthDp == 220 ) {
// load layout dashboard_view_220.xml
} else {
// load layout dashboard_view.xml
}
I want to apply view binding here. The problem is as I have 2 layouts with different name so 2 binding class is generated. So, I have to use if else
condition like below
if(config.screenWidthDp == 220) {
dashboardViewBinding220.title.text = ..
} else {
dashboardViewBinding.title.text = ..
}
Is there any way I can avoid this condition or any good approach for my current scenario.
Thanks in advance.