There is a fragment, that is in portrait mode, then I replace that fragment with another, and I want it to be displayed in landscape mode, even if I hold my phone in portrait mode. (Both are in the same activity, and I don't want to change that.) If I simply put the layout file in the layout_land folder, than the app crashes. I can't define it in a layout xml tag like android:screenorientation="landscape", because i must add and replace fragments programatically. Any idea?
Asked
Active
Viewed 1,900 times
1
-
Activities are portrait and landscape. Fragments do not have an orientation. Hence, there is no concept in Android of displaying a fragment in landscape mode, except by displaying its hosting activity in landscape mode. – CommonsWare Mar 13 '12 at 13:30
-
so there is no way to display two fragments with different orientation within the same activity? – czadam Mar 13 '12 at 13:32
-
Generally, you are correct. It is *conceivable* that the new animation effects available in API level 11+ might allow you to accomplish the same effect, by rotating the widgets in a fragment to your desired perspective. I have not tried this, particularly for widgets accepting user input, and the classic `RotateAnimation` would not handle this scenario (input would be portrait even if output would be landscape, in effect). – CommonsWare Mar 13 '12 at 13:36
-
http://stackoverflow.com/questions/584779/android-switching-between-landscape-and-portrait-mode-makes-intent-lose-values – Karthi Mar 13 '12 at 14:00
2 Answers
0
You could give false informations to your accelerometer litener.. it's not very pretty but should work

Renaud Favier
- 391
- 6
- 20