android layout landscape/portrait with different options -


is there way directly tell android layout resource choose landscape or portrait mode?

i know it's simple, put normal "main_layout.xml" in "res/layout" folder , landscape "main_layout.xml" in "res/layout-land" folder.

now assume have 2 layouts called "main_layout_blue.xml" , "main_layout_red.xml". user can choose 1 of them , can set appropriate layout. on orientation change again fine.

where stuck giving user option set different layouts different orienations "main_layout_blue.xml" portrait mode , "main_layout_red.xml" landscape mode.

is there android option explicitly tell system use "res/layout/main_layout_blue.xml" portrait orientation , "res/layout-land/main_layout_red.xml" landscape orientation? missing here?

after orientation change, view recreated can check orientation of device following:

activity.getresources().getconfiguration().orientation 

and based on result can:

   if(portrait)       setcontentview(r.layout.blue)    else       setcontentview(r.layout.red) 

but keep in mind put of resources in /layout folder


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -