emulation - Android emulator, creating and AVD with screenLayout = SIZE_LARGE -
this question has answer here:
- get screen size bucket programmatically? 8 answers
i'm developing app targeting android 4+, behaves differently depending on screen size. more in detail:
- on small/medium screens, orientation forced on portrait, , app runs switching activities.
- on large/x-large screens, orientation forced on landscpe, screen split two, menu fragment on left, , other fragments on right.
problem is, can't create avd gets detected large screen.
just tested on avd 640x1024 resolution, 240 density, code never goes first if.
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // forcing layout landscape if display large or more if ((getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) == configuration.screenlayout_size_large || (getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) == configuration.screenlayout_size_xlarge) { setrequestedorientation(activityinfo.screen_orientation_landscape); dualpane = true; } else { setrequestedorientation(activityinfo.screen_orientation_portrait); dualpane = false; } }
any help?
assuming have android sdk plugins eclipse installed, can create emulator uses large layouts:
- in eclipse, click on little green android button (to "open android virtual device monitor").
- new...
- name = [whatever]
- target = android 4.x
- cpu/abi = [whatever] intel emulators better/faster.
- resolution = 1024 x 600. important part. don't use 600 x 1024. it must landscape device (like 'mini tablet')
- also important: set density manually mdpi: click on "abstracted lcd density" -> change number 160 mdpi.
- create avd
now start device. use large layouts (configuration.screenlayout_size_large). rotate portrait using ctrl+f11. portrait mode use large layouts.
Comments
Post a Comment