support for different screen sizes in android -
i want apps support different screen sizes. add folders "layout-small , layout-large " in /res directory. xmls inside folders aren't accessible in activity.so add xmls in default layout , add code
if((getresources().getconfiguration().screenlayout && configuration.screenlayout_size_small) == configuration.screenlayout_size_small) { setcontentview(r.layout.main1); }else if((getresources().getconfiguration().screenlayout && configuration.screenlayout_size_large) == configuration.screenlayout_size_large){ setcontentview(r.layout.main2); } else setcontentview(r.layout.main); in activity, when avd skin 1024*600 , hw.lcd.dencity 160 (large) didn't work.
any help?
size: small, normal, large
density: ldpi, mdpi, hdpi,
nodpi(no auto-scale) aspect ratio: long, notlong
orientation: land
usage:
res/layout/my_layout.xml res/layout-small/my_layout.xml res/layout-large/my_layout.xml res/layout-large-long/my_layout.xml res/layout-large-land/my_layout.xml res/drawable-ldpi/my_icon.png res/drawable-mdpi/dpi/my_icon.png res/drawable-hdpi/my_icon.png res/drawable-nodpi/composite.xml restricting app specific screen sizes(via androidmanifest):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> ... <supports-screens android:largescreens="true" android:normalscreens="true" android:smallscreens="true" android:anydensity="true" /> ... </manifest> and code level tweeking:
float scale = getcontext().getresources().getdisplaymetrics().density; and don't forget:
dpi = 160; //at 160dpi pixels = dips * (density / dpi) also refer support multiple screen in android
Comments
Post a Comment