androidlayoutresponsive-slides

android phone and tablet layout


I have a simple app that works well for phones, with the following structure:
enter image description here

Now, I want to take better advantage of the unused space when the user is
using the app in a tablet or in landscape mode. Pretty much like this:

enter image description here

Is there any way I can make a check (resolution or device type) that I can
switch the xml layout from phone_layout.xml to tablet_layout.xml on onCreate?

OR I should be using fragments for this?
Thanks.


Solution

  • You can make use of the resource buckets.

    Basically you will have to create two layout files with the same name in two different resource folders:

    The system is intelligent enough to pick the right layout based on the running device as long as you name your layouts the same.