1

When screenOrientation="portrait", it looks like:

enter image description here

When screenOrientation="landscape", it looks like:

enter image description here

You can see only the center view has been rotated, others are not changed.

Is it possible in android, and how to implement it if yes?

Freewind
  • 193,756
  • 157
  • 432
  • 708
  • Ultimately, it simply uses the layout-land xml of the layout. You can make this layout look how you want rit? – Aswin Kumar Sep 18 '12 at 06:27
  • as Aswin suggested, you should use laout-land; but you really wanna rotate it, see [this example](http://stackoverflow.com/questions/5894736/rotate-zoom-drag-image-in-android-imageview) – Manoj Kumar Sep 18 '12 at 06:30

2 Answers2

1

See: http://developer.android.com/guide/practices/screens_support.html

The part about orientation

for example:

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

Or in code. Fill in the code for changing the layout yourself.

Activity:

public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
    }
  }

Manifest:

<activity android:name=".MyActivity"
          android:configChanges="orientation"/>
Klaasvaak
  • 5,634
  • 15
  • 45
  • 68
  • I'm afraid there will be a lot of duplicated code in these 2 layouts. Do I have to define some partial layouts to be included in the these 2 layouts? – Freewind Sep 18 '12 at 06:32
  • You can change the interface components aswell in the code. I added that code. – Klaasvaak Sep 18 '12 at 06:33
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.

Gan
  • 1,349
  • 2
  • 10
  • 27