开发者

screen orientation

开发者 https://www.devze.com 2023-02-07 14:42 出处:网络
Hi M new to android.I faced a problem i.e in landscape mode i need a layout view which doesnot havesome feilds which are present in the portrait mode.I have created a layout for landscape view in su

Hi M new to android.I faced a problem i.e in landscape mode i need a layout view which doesnot have some feilds which are present in the portrait mode.I have created a layout for landscape view in such a way.In the activity i have given the conditions like if portrait display some feilds some hide.its working properly actually...first when i go from portrait t开发者_如何转开发o landscape it is giving what i want...but when i go to portrait mode its stopping the application.please help me.Thanks in advance


You can make two different layouts and put them in layout-port and layout-land respectively. And make sure that you have mentioned android:configuration = "orientation" in your manifest for that activity. Try it if i have understood you correctly.


I think that the advice by Kantesh may be backwards. As explained in the docs, if you include android:configChanges="orientation" in the manifest, then the correct resource (from layout-port or layout-land) won't be automatically loaded. Instead, leave out mention of orientation from the manifest. Then, you do not need to worry about onConfigurationChanged() (don't override it). The system will automatically shut down the activity and then restart it, binding the appropriate version of configuration-dependent resources. Handling configuration changes yourself is (again, according to the docs) only a last resort to deal with performance issues that cannot be handled in other ways.

0

精彩评论

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