0

I've got an app made for tablets, where I'm using RelativeLayout. For smaller screens I'd made TabLayout where that RelativeLayout is splitted on 3 tabs. That 3 tabs are 3 separated xml files. My problem is connecting code to both layouts. On tablet, everything is in one xml so I can e.g. call:

setContentView(R.layout.tablet_layout);
button = (Button) findViewById(R.id.btn1);

but for smaller screens it is in three xml files so it won't work like that. Is it possible to do something with that?

waclab1807
  • 71
  • 5
  • Have you tried to get the Diagonal Screen Size and select wich xml set depending on the size? – UrielUVD Apr 16 '15 at 17:05
  • How about creating two layouts with same ids for the various sb layouts and using `getWindowManager().getDefaultDisplay()` to get the screens width and height. When inflating, the appropriate layout files at onCreate() or onCreateView(), depending on the values of the screen dimensions you can use one of the two. – Vaibhav Singhal Apr 16 '15 at 17:10
  • I've tried that getWindowManager().getDefaultDisplay() and it's good, thank you. I can make condition to switch layouts now. But I still have problem, how to set setContentView() method to three xml files? – waclab1807 Apr 17 '15 at 12:18

0 Answers0