开发者

View Changes In Force Portrait Mode

开发者 https://www.devze.com 2023-03-14 10:28 出处:网络
i am new in android platform. I have set my android application to force portrait mode. Now , i have an activity group in my application. When i am in a child view of the activity group , then if i ro

i am new in android platform. I have set my android application to force portrait mode. Now , i have an activity group in my application. When i am in a child view of the activity group , then if i rotate my device the screen remains in portrait mode but the view changes from child view to parent view of the activity group. I don't know why this is ha开发者_开发百科ppening. So please help me on the issue. Thanks in advance .... !!!


You have to add android:configChanges="keyboardHidden|orientation" to every Activity node within a ActivityGroup in your application's manifest file when your application is on force portrait mode. Thus the view will not change.


I guess you missed something... You have to add 2 things to your activity in your manifest file.

android:screenOrientation="portrait" This one will keep the activity in the portrait mode itself, and wont change the orientation. But whenever you change the orientation of you device, The activity will try to restart. That is why your app came back to the parent activity. To avoid that we use the below config.

android:configChanges="keyboardHidden|orientation" When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.

http://developer.android.com/guide/topics/manifest/activity-element.html#config

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号