I am working on android. How to get landscape and portrait view in android tablet ?
If you rotate your tablet to landscape, then you get the landscape view, otherwise you get the portrait view.
in the emulator, use KEYPAD_7 (or Ctrl-F11) and KEYPAD_9 (or Ctrl-F12) to cycle through the layout orientations.
Related
Here I am using different UX designs for portrait and landscape mode for a particlular activity. Created the folders layout-sw600dp and layout-sw600dp-land ,layout-sw720dp and layout-sw720dp-land for portrait and landscape mode. But the corresponding UX is not displayed while changing the mode. That is it loads the launching mode's expanded version while rotating the device. This means it will show the expanded version of landscape design while changing that to portrait. Tried the below code in the manifest. But no hope.
android:configChanges="keyboardHidden|orientation|screenSize"
Right now I have two different layout files, one for Large and one for large-land. Both are using constraint layouts. However whenever the tablet switches from portrait to landscape mode, the landscape mode layout displays correctly. But after switching back to portrait and back to landscape mode, the landscape layout no longer displays correctly. The right side of the layout seems to have extended past the actual screen.
To simplify,
Portrait -> Landscape: Landscape displays correctly
Portrait -> Landscape -> Portrait -> Landscape: Landscape layout breaks and extends past the screen for some reason.
Any idea why this may be happening? Thanks in advance!
I am developing an android application that supports multi-windows feature on Android 7.0.
I followed this guide on https://developer.android.com.
, imported sample project https://github.com/googlesamples/android-MultiWindowPlayground
I create a new resource named layout-land and did some testing. I recognized that landscape layout is inflated even though the device is in portrait mode.
Check out attached images.
How can I set portrait layout when device is in portrait mode.
Assume you have two screens. One is in landscape and one in portrait.
How can you say which one is in landscape and which one in portrait?
In portrait width of the screen is less than height.
And for landscape width of the screen is greater than height.
Agree?
So, here, when you enter multiwindow mode your app's window no longer fits screen - width is greater than height and it is considered as landscape.
That is why landscape layout resource is used.
There is no separate modifier for layout resource to be used in split-screen mode.
The only thing you can do to achieve portrait in your case is to remove layout-land.
Or you can create two separate layouts (without any modifiers such as -land) and in activity call activity.isInMultiWindowMode(); to choose corresponding layout you want to use.
I have implemented an application for android 7 incs tablet.In my application i have used two types of layouts in layout-land and layout-port directories with same xml name and different designing.
In this application the tablet view is in landscape mode as by default when i change the orientation of emulator the the view is calling portrait xml from layout-port and if again change emulator orientation it is not getting xml view from layout-land.
I have implemented my application as follows:
if(wm.getDefaultDisplay().getOrientation()==1){
//portrait view code
}
else{
//landscape view code
}
from the above logic i can get the view from land scape to portrait but i can't get same view portrait to landscape.
How can i get my land scape view when i change landscape to portrait to landscape?
please any body help me?
That seems to be a problem with the emulator. You don't have to implement from code the orientation changes, since the system have by default this behavior. Just place your xml files in layout-land and layout-port and on a real device it will work fine.
The bug has been reported and you can see this here
You can use this code:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
You maybe also have to set this in your manifest under activity:
android:configChanges = "orientation"
I m trying to run the code given here - http://code.google.com/p/android-honeycomb-fragment-tutorial/source/browse/#svn%2Ftrunk%253Fstate%253Dclosed on a 7 inch emulator in portrait or landscape using the android support package. Well from the code its obvious portrait shouldn't show up the fragments but neither is landscape.
But no matter what I do I am not able to see the fragments in the screen. Is there a minimum screen setting for seeing the different fragment screens in Android?
There is no minimum screen setting for fragments to be show on Android.
You see only one fragment because they have a single fragment in both the activities in the Portrait mode.
Portrait : http://code.google.com/p/android-honeycomb-fragment-tutorial/source/browse/trunk/res/layout/main.xml
In the Lanscape mode there are two fragments shown, and these should show up
Landscape : http://code.google.com/p/android-honeycomb-fragment-tutorial/source/browse/trunk/res/layout-land/main.xml