When screenOrientation="portrait"
, it looks like:
When screenOrientation="landscape"
, it looks like:
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?
When screenOrientation="portrait"
, it looks like:
When screenOrientation="landscape"
, it looks like:
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?
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"/>
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.