I have a ViewFlipper with several ScrollViews inside. Depending on the child ScrollView I need to force the ViewFlipper's orientation to portrait or landscape. How can I achieve this ? Thanks.
Take a look at http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/reference/android/widget/HorizontalScrollView.html
In the first document, note that you can provide different layout files for landscape versus portrait modes. For example, for landscape mode, you could have a layout file in res/layout-land.
If you want more help putting the pieces together, just ask.
Edit: It looks like I misread the original question. Take a look at these two posts:
Force an Android activity to always use landscape mode
Android force Horizontal (landscape) layout
Related
I stuck in a little bit problem. I have situation like this:
Login activity with one layout.
Three Fragment every one with three different layouts, (Phone portrait, landscape, Tablet landscape)
For better image, Fragments function is: login, register and confirmation code.
What i want to achieve is, good screen rotate + after rotate open correct fragment with stored register data.
I'm not sure if it will helpful but i use in project greenrobot event bus.What i need is suggestion how i could implement it correctly. Which is best approach etc.
Thank you for your feedback!
You should use quantifiers to load the great layout depending on your screen size and orientation.
For example, activity_main.xml from layout-large-land and layout folders wont react the same. The first one will only be loaded if you are on a tablet and landscape oriented. The second one will be the default layout.
You will need to use small, large, landscape (land) and portrait (default) quantifiers.
About loading datas, you can use saveInstanceState bundle. Note that views with an id will automatically handle it.
I want to make a picture gallery with a vertical layout with two parts: image on
top, and horizontally scrollable icons below. I know how to do this.
But I also want that, when autorotated, icons stay on the right. That is, I want
to change the vertical layout by a horizontal one, and horizontal
scrollbar by a vertical one.
How to do this? Any clues/links would be appreciated.
Thanks!
L.
You'll want different layouts for each orientation (landscape, portait) and possibly more for different screen sizes. Start with the android documentation.
If you have specific issues, post the issue(s), some code for what you have tried and we'll see if we can help you.
you must have multiple layouts. create 2 layouts. one in layout folder for portrait and copy it and paste it in layout-land folder for landscape then customize each other.
I have downloaded the google io application and I noticed that for landscape layout, its only the dashboard layout that have a landscape layout (in the layout-land folder).
My question is the following, is it for all the layout available in our project that we must create a landscape layout or it is only for the dashboard layout?
Thanks.
Kind Regards.
You are allowed to create a landscape layout for any layout in your app. You should do this when you want to have a different layout in portrait vs. landscape. Sounds to me like the Google IO app specifies a different landscape layout for only one screen (the home screen/dashboard), presumably because that's the only screen the developers felt needed a different landscape layout. Point is, it's up to you which screens have alternate layouts.
It depends on the data you have to show.
Sometimes there is more data which can be shown because of extra width in landscape and you have to compress data vertically in landscape. For such cases use different layouts
Can we fix the orientation for one imageview in framelayout, and orientation of other children of frame layout be controlled by the sensor?
I want to fix the orientation of image in background and on top of that need to show some reults in textviews. If I fix the activity in landscape then I can't draw the text portrait wise.
You can use separate xml for portrait and landscape mode.
1.you have to create separate folders layout-land, layout-port
2.save the xml in it.
3.Be sure with both have the same name.
You can refer here
Orientation can only be applied on activities,we cannot set the orientation of views.
I developed an application in portrait mode in Android.
What changes do I have to do, that my application will be also fit for landscape orientation?
Thanks in advance.
Technically speaking, you don't HAVE to make any changes for it to fit to landscape. It you're using the standard wrap_content and fill_parent for your width and height, your layout will automatically adjust when you change orientations.
With that said, you will often WANT to change to a different layout when switching from portrait to landscape, as a layout that looks good vertically may be unusable when horizontal. You can add a new folder beside your /layout folder titled layout-land. In this, make a new XML file with the same title as your previous layout, and then change the layout from there. Be sure that any and all defined android:ids exist in both the original and landscape layout.
Make sure you use layout_width as "fill_parent" where ever required.