开发者

How to Handle mobile screen orientation android

开发者 https://www.devze.com 2023-03-13 19:14 出处:网络
i want to know how to handle mobile screen orientation means in android mobile if i make the mobile horizotal then it\'s layout also be horizontol and when i turns it to verical then it\'s layout beco

i want to know how to handle mobile screen orientation means in android mobile if i make the mobile horizotal then it's layout also be horizontol and when i turns it to verical then it's layout become vertical..but when i make horizontol th开发者_如何学JAVAen my UI becomes change and unlike to me..

1) so is there any way so that when i make it horizontol then my UI automatically set according to that heiht and width. and my

2) second qus is that if i not want to change the orientation when i make it horizontol means if i make mobile horizontol then also its orientation will not change and it remains same.


You should have two layout for both Landscape and Potrait and put your landscapelayout to layout-land and protrailayout to layout folder . Android will automatically do the rest of the things for you .

if you are in landscape or portrait Android looks for the layout file in either the -port or -land directory first, if it's not found then it falls back to the default layout directory.

you can read it here..http://developer.android.com/guide/topics/resources/providing-resources.html


Add this in your Manifest file in your activity for the fixed orientation you want for your Activity

android:screenOrientation="portrait"

like

<activity android:name=".Settings" android:label="@string/app_name" android:screenOrientation="portrait">
0

精彩评论

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

关注公众号