In my xml, i have small, normal, large and default layout set.
I don't want device auto select layout set but i want to select base on device width's resolution.
This is my manifest.xml
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" >
</supports-screens>
How to set it?
In your project's
res/
directory, you would include layout folders for each screen size you support. The possible folder names would belayout-small
,layout-normal
,layout-large
andlayout-xlarge
. If you omit one or more screen size folders, Android will use the next closest folder that is equal to or less than that size, and it is also recommended that you have a "default" folder simply calledlayout
that can be used as a catch-all (recommend using this instead oflayout-small
). Inside each folder you would generally place an xml layout file specific to that screen size and all of the files would have exactly the same name (ex.layout-normal/my_layout.xml
,layout-large/my_layout.xml
, etc.).From within your
Activity
'sonCreate()
method you would callsetContentView(R.layout.my_layout)
, which would automatically select the correct layout from the folder matching the screen size of the device.Here is a very comprehensive document that explains designing applications for different screen sizes, includes the information mentioned above.