Well, I am currently developing an app in android studio but I have focused on making it look good on cell phones, but I have neglected to make it look good on devices such as tablets or elements that are larger than a cell phone. I would like to know how I can make my screens, either the location of my components, change depending on the dimensions of the device on which the app has been installed.
To do this precisely, there are the folders destined for this purpose where the corresponding layouts are created, including the image folders destined for the corresponding density.
The directories for layouts are:
In the case of tablets from Android 3.2, new qualifiers were added :
https://developer.android.com/guide/practices/screens_support.html#NewQualifiers
Where you can set a difference when loading your layout depending on the pixel density, for example:
As for the images, the directories for images are:
For more information you can review the documentation:
Providing Resources in Android
Support Multiple Screens
You can also detect if your device is a tablet using the method suggested by Google:
And based on this load a layout that you have defined within the directory
res/layout
which contains a different distribution of elements.The loading of this layout defined for tablet would be done through the method
setContentView()
when loading your Activity:What you have to do is create different layouts depending on the size of the device:
If, for example, you want to create a design for tablets, you must create a folder called
layout-large
olayout-xlarge
:I recommend that you read this documentation:
Support Multiple Screens
Providing Resources