1

当 时screenOrientation="portrait",它看起来像:

在此处输入图像描述

当 时screenOrientation="landscape",它看起来像:

在此处输入图像描述

你可以看到只有中心视图被旋转了,其他的没有改变。

在android中是否有可能,如果可以,如何实现?

4

2 回答 2

1

请参阅: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"/>
于 2012-09-18T06:28:16.760 回答
0

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.

于 2012-09-18T09:13:11.380 回答