当 时screenOrientation="portrait"
,它看起来像:
当 时screenOrientation="landscape"
,它看起来像:
你可以看到只有中心视图被旋转了,其他的没有改变。
在android中是否有可能,如果可以,如何实现?
当 时screenOrientation="portrait"
,它看起来像:
当 时screenOrientation="landscape"
,它看起来像:
你可以看到只有中心视图被旋转了,其他的没有改变。
在android中是否有可能,如果可以,如何实现?
请参阅:http: //developer.android.com/guide/practices/screens_support.html
关于方向的部分
例如:
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/layout-xlarge-port/my_layout.xml // layout for extra large in portrait orientation
或者在代码中。自己填写更改布局的代码。
活动:
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
}
}
显现:
<activity android:name=".MyActivity"
android:configChanges="orientation"/>
Since your requirement is to view the image in correct orientation in different layouts, I would suggest you rotate the image rather than providing alternative resources which means you have to make everything rotated (i mean the text inside the button, has to be rotated. The same goes for the other components).
You can detect the orientation changes and just rotate the imageview alone which would save you a bit of work.
You can take control of the orientation changes by specifying it in the manifest of the activity as follows.
<activity android:name=".MyActivity"
android:configChanges="orientation|screenSize"/>
you can then override the onConfigurationChanged(Configuration newConfig) method as suggested by klaasvaak and just rotate the image. You can follow the link to see how to rotate images.