How to set android layout to support all screen sizes?
Please go through the following links. These might help you:
Supporting Different Screen Sizes
Supporting Multiple Screens
Supporting Different Densities
Supporting Tablets and Handsets
AFAIK, the only way to support all screens is by doing that folder bifurcation. Every XML file goes up to a few kilo bytes. So, size shouldn't be too much of an issue as such.
How to make an Android App Support all Screen Sizes?
Read supports-screens
If your application does not work well when resized to fit different screen sizes, you can use the attributes of the element to control whether your application should be distributed to smaller screens or have its UI scaled up ("zoomed") to fit larger screens using the system's screen compatibility mode.
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:normalScreens="true"
android:anyDensity="true"/>
For more info read Screen compatibility
Supporting all screen sizes in android?
Basically some devices belongs to large or normal group but they have so much difference in height and width for example- Nexus-4 4.7"
having dimensions 768x1280
and one other device 5.1"
having dimensions 480x800
. So you can create layouts folders depending upon height and width. For example- layout-w480dp, layout-w720dp or layout-h800dp or layout-h1280dp
. Then set views in those layouts according to your requirement.
Android layouts for different screen sizes
The answer is already given by user5594218 but looks like you are still unclear. (maybe you are beginner)
So, here is the step by step guideline
Solution 1: (short and simple)
Navigate to
app > src > main > res
Duplicate layout directory by copying and pasting
Rename duplicated Directories e.g
layout-sw300dp
Solution 2: (bit lengthy)
- Create new resource directory:
res > New > Android resource directory
Select
Resource Type
aslayout
Add
sw<N>dp
in Directory name e.glayout-sw300dp
and Hit OK
Navigate to
app > src > main > res
Copy layouts XML file inside new directory
//repeat process for other qualifiers
List of Qualifiers to support all screens:
- layout-sw300dp
- layout-sw330dp
- layout-sw480dp
- layout-sw600dp
- layout-sw720dp
Testing:
This is how it gonna look like, if you did it right.
For more detail and examples, check: Android Application Development All-in-One For Dummies
Related Topics
How to Marshall and Unmarshall a Parcelable to a Byte Array with Help of Parcel
Different Font Size of Strings in the Same Textview
Loading Existing .HTML File with Android Webview
Custom Facebook Login Button - Android
Schedule a Work on a Specific Time with Workmanager
How to Make a Gridlayout Fit Screen Size
Round Corner for Bottomsheetdialogfragment
Android Background Image Size in Pixel
Filtering Listview with Custom (Object) Adapter
Transitive Dependencies for Local Aar Library
Android - Local Image in Webview
How to Handle Handler Messages When Activity/Fragment Is Paused
Unexpected Value from Nativegetenabledtags: 0
How to Set Up Android Emulator Proxy Settings
Android Spinner:Avoid Onitemselected Calls During Initialization
Android Dialogfragment VS Dialog
Android: How to Make a Clickable Map Image with Each Country Producing a Different Action