I´m a little familiarized with android development, so I will do a magazine app, with some pages using imageviews, one requisite is the app will work in Landscape and Portrait mode, but with one diference, in Portrait will show one page, Landscape will show 2 pages. I always worked with others developers that did the layout, but this time I will do all work. The pages will change using swype method, so I think using a android view pager is an adequate method to do this: http://developer.android.com/training/animation/screen-slide.html but I need to change between a portrait and landscape view, how can I do this?
You can create a layout to landscape mode and other to portrait. For example you activity_main.xml layout is on folder res/layout you can create a version on res/layout-land with the same name.
for more details please read: http://developer.android.com/guide/practices/screens_support.html#qualifiers
Related
I have an activity which contain 3 fragments. 2 of them have data in a listview therefore when user rotate the screen everything is ok. but on my third fragment which contain buttons, when the user rotate the screen to landscape orientation,everything goes astray!
my third fragment in protrait orientation
my third fragment in landscape!
I have even tried to use scrollview but it's not working because when in landscape i don't want that big space at the middle. i wan't 3 x 2 buttons arrangment(i have 6 buttons.) when in landscape. and i think i can only achieve that by using 2 xml layouts for my fragment.
Question is how can i do that?
Make another layout folder layout-land under res and create landscape orientation layout file under this folder
After great help from sai Phani(see his comments above). i finally achieved my objective which was to create a landscape layout for my fragment by doing the following.
Create a folder under src\main\res and call it layout-land
copy your fragment layout xml (e.g peoplefragment.xml) which is in src\main\res\layout and paste it into src\main\res\layout-land folder. Don't change the file name!
Once you have pasted it, you can change the views alignment the way you would like them t appear on landscape. for my sutuation, i wanted them to appear like this in landscape
You may design your layouts that looks good for both portrait and landscape but you may customize for both orientation.
Look at SO link on the same issue # Android: alternate layout xml for landscape mode. The idea is simply to create folder names the correct way specified in Google documentation.
A good Google webpage is # Supporting Multiple Screens, search for "Using configuration qualifiers". There is a table stating Orientation and the folder names to use.
Wondering how I do build a layout with self rearranging button, when the user turns his device from portrait to landscape, using relativelayout ?
I do not want to use scrolling on my layout and I have a lot of buttons
You can provide two different main.xml (or any layout xml file) Place one in res/layout/ and one in res/layout-land/ When the device switches orientation the system will handle the "magic" of switching to the appropriate file.
Here is some documentation about supporting these type of behaviors...
If I'm understanding your question correctly what you are looking to do is have one layout displayed for portrait mode and another for landscape mode. This is actually fairly easy to accomplish.
Here is a link to a quick tutorial:
How to change your layout in Android landscape / portrait mode
Is there any way in order to make a single layout for tab widjets and when changing orientation from portrait to lanscape single layout is called.
Which properties and how the properties are changed.
Just create the layout and android will do the rest is the simple answer. See the Tab Widget Layout tutorial on the on the Android developers site for a code example. It handles correctly with both portrait and landscape orientations.
Hi guys in my android application i have used Tabs through out the application.When iam in the Portrait orientation i need to display the Tabs.Whenever iam in the Landscape orientation i need to put a layer just above the TabBar so that the TabBar will be in the background.Here in the Landscape orientation the background TabBar runs ,that is just we have added one layer on top of the TabBar.And also i need to display different layout in the landscape orientation.I have heared about the Window object of the Current Activity that we can add a XML layout to the Window and makes it visible and invisible whenever we require.But i haven't find any code regarding Window.Any Suggestions
You can define different layouts for each orientation. For portrait layouts use the layout-port folder, for landscape use layout-land. Android will choose the right one depending on the orientation of the device.
See http://developer.android.com/guide/topics/resources/providing-resources.html
I worked in a tabactivity, I set the gravity for tabs as bottom. If I change the screen from portrait to landscape, I can't see the tabs.
How can I do it? I need an example please.
Thanks.
Assuming you do not have a separate XML file dedicated to landscape format, you might need to create one and specify the landscape-layout look.
Create another main.xml file with the specifics of how your program should look in landscape mode. The file shoud reside inside your res/layout-land/ folder.
When that is all said and done, in potrait orientation, Android will use main.xml found in res/layout and in landscape main.xml found in res/layout-land.