Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What layout folders are required to support all Android Devices?

I am developing a Calculator App which have a Relative Layout for Portrait Mode. All Buttons and TextViews are placed in this single Relative Layout and a same Relative Layout for Land mode. I have been digging web for almost 15 days but found nothing relevant. My App also have support for Tablets. MinSDKVer is 14 and Target is v21.

Currently I am trying these Layouts folders

1:layout-sw400dp (intended for Note 3 and Mate 7)

2:layout-sw600dp (intended for 7" Tablets)

3:layout-sw720dp (intented for 8.9" and 10" Tablets)

4:layout-small-ldpi

5:layout-normal-ldpi

6:layout-normal-mdpi

7:layout-large-mdpi (intended for 480×800 phones with screen >5" like Pantech Sky Vega Note)

8:layout-normal-hdpi

9:layout-large-hdpi (intended for Galaxy Note 2, Galaxy Note and Galaxy Mega)

10:layout-normal-xhdpi

11:layout-normal-xxhdpi

12:layout-large-xxhdpi(intended for Galaxy Note 4)

13:layout-normal-xxxhdpi(intended for Nexus 6 and for other QFHD Phone)

All these layouts have land mode.

Problem arouse when I placed (layout-sw400dp). Nexus 6, Note 4, Note 2, Galaxy Mega and Large 480×800 phone started using this layout rather than intended layouts.

This is happening because swdp has a higher precedence than layout-normal-xxxx or layout-large-xxxx.

Note 3 and Mate 7 are 400dpi devices that is why I placed layout-sw400dp. Before that all devices were working perfectly except, Note 3 and Mate 7.

And other problem is devices with 540×960 resolution.

I have tried layout-320dp. By using this xhdpi devices and xxhdpi devices started using this layout.

I have also tried these layout for 540×960 But these did not work even after making seprate folder for layout-long-port-800×480.

1:layout-h960dp-w540dp

2:layout-long-port-960×540

3:layout-normal-960×540

I took all screens reading from Android Virtual Device Manager by creating different devices with actual specifications.

I have tried manually setting layout for 540×960 devices in java file and succeeded but I don't want to do that and I don't want to use Linear layout either.

I have thoroughly studied "Android Different Screen Support and Providing Resources".

Please tell the name of all required folders for layout to support all android devices or any other efficient way to do this using java.

I have uploaded all resources files on Mediafire you can Download Calculator Layout.zip

Any suggestions and solutions will be appreciated Thanks in advance

Sorry for English because it is not my native tongue.

like image 707
Kamil Mahmood Avatar asked Mar 19 '15 06:03

Kamil Mahmood


People also ask

What are the layouts available in Android?

Android Layout TypesTableLayout is a view that groups views into rows and columns. AbsoluteLayout enables you to specify the exact location of its children. The FrameLayout is a placeholder on screen that you can use to display a single view. ListView is a view group that displays a list of scrollable items.

Which layout is best in Android?

Use FrameLayout, RelativeLayout or a custom layout instead. Those layouts will adapt to different screen sizes, whereas AbsoluteLayout will not. Definitely right. I recommend RelativeLayout since it keeps the view hierachy flat.

Where are the layout files placed in Android?

Layout files are stored in "res-> layout" in the Android application. When we open the resource of the application we find the layout files of the Android application. We can create layouts in the XML file or in the Java file programmatically. First, we will create a new Android Studio project named "Layouts Example".


1 Answers

Instead of using so many simple layout folders, use following folders.

For Smartphones

1.layout:Normal

2.layout-hdpi: use the Nexus one,Nexus S

3.layout-xhdpi : use the Nexus 4

4.layout-xxhdpi : use the Nexus 5

5.layout-xxxhdpi : use the Nexus 6

For Tablets

1.layout-large : use the Nexus 7

2.layout-xlarge: use the Nexus 9

3.layout-xxlarge: use the Nexus 10

like image 120
suresh madaparthi Avatar answered Sep 16 '22 18:09

suresh madaparthi