I have two 7 inch tablet one tablet (800*480) and second tablet (1024*600). I have facing problem following :-
1. Both can run on layout-mdpi and layout-large so how can i make different folder for run my app both resolution.
Application run xml for mdpi layout in both tablet:-
layout-mdpi
layout-hdpi
Application run xml for large layout in both tablet:-
layout-large
layout-xlarge
I can implement http://developer.android.com/guide/practices/screens_support.html this but not use full to me.
or
try so many link but still same problem both tablet running in same layout.
Try using this.It worked for me
layout-sw600dp
7" tablets—Android 3.2 introduces a new way to specify resources for more discrete screen sizes. The new technique is based on the amount of space your layout needs (such as 600dp of width), rather than trying to make your layout fit the generalized size groups (such as large or xlarge).
res/layout-sw600dp/
res/layout-sw600dp-land
res/layout-sw600dp-port
- 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
hdpi, etc).
- 480dp: a tweener tablet like the Streak (480x800 mdpi).
- 600dp: a 7” tablet (600x1024 mdpi).
- 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
UI to differentiate between sizes such as 7” and 10” tablets
- res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
- res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
- res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
xlarge is a configuration qualifier for extra large screens.* When you append this string to a resource directory name (such as layout-xlarge), it indicates to the system that these resources are to be used on devices that have an extra large screen.
I have two 7 inch tablet one tablet (800*480) and second tablet
(1024*600). I have facing problem following :-
I have faced the Same issue. as a workaround i have make the xml file for (800*480) in same layout folder as Default.
Also used layout-sw320dp for the Devices like GalaxyNexus
and for 7'' Tablet i have make layout-sw600dp for 7'' Screen Tablet
and for 10'' Tablet i have make layout-sw700dp for 10'' Screen Tablet
For Example : you have the xml file named "activity_main.xml"
1) inside layout
folder--> put activity_main.xml with layout according
to nexus one(480*800 hdpi)
2) inside layout-sw320dp
folder--> put activity_main_tab.xml with
Layout according to Galaxy Nexus(720*1280 xhdpi) Device which
should take the layout from layout-600dp
but will take layout from
layout-320dp
3) inside layout-600dp
folder--> put activity_main_tab.xml with layout according
to tablet 7'' Screen
4) inside layout-700dp
folder--> put activity_main_tab.xml with layout according
to tablet 10'' Screen
after making the Layout formated as above. i have checked runtime width and height of device. and set the layout file accordingly.
if (displayWidth >= 552 && displayHeight >= 976 || displayWidth >= 976
&& displayHeight >= 552) {
Log.i(TAG, "in tab xml");
setContentView(R.layout.activity_main_tab);
}else{
Log.i(TAG, "in Simple xml");
setContentView(R.layout.activity_main);
}
Hope this will Help.