android - Different layouts for portrait and landscape modes based on screen width, not orientation per se -


i have 2 versions of layout, smaller screens , larger screens. incidentally, have device different layouts required in different orientations. on other device may not so. want base on screen width, not orientation such.

i've read this article , noticed "available screen width" (w<n>dp modifier) can used specifying proper layouts. says:

the system's corresponding value width changes when screen's orientation switches between landscape , portrait reflect current actual width that's available ui.

sounds perfect. put smaller layout in base layout folder, , larger 1 layout-w750dp. , larger layout picked. problem doesn't switch base layout when rotate device portrait mode.

i have used code this answer check screen width in dp. it's 960 in landscape , 600 in portrait. made sure android:configchanges="orientation" not specified activity. have put log activity's oncreate() - indeed called when rotate device, should have received correct layout?.. why doesn't work , how make work?

update: launching activity (and whole application) in portrait mode right start still picks w750dp layout.

update 2: layout-land didn't work either. layout still picked in portrait mode. odd. it's becoming clear issue has little width general functioning of resource selectors.

comments getting long answer.
tested on tablet (768x1024 dp) 2 layouts first in layout, second in layout-w900dp , works fine.
second layout shown in landscape mode correct because 900 < 1024.

note: used getresources().getconfiguration().screenwidthdp screen width!

so it's problem on side :)
ether messed layouts or android studio messing :d.

sorry lack of more definitive answer :/


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -