MultiScreen ListView Android does not work well when rotated - android

Hello guys i have problem with my Listview . I have different layout for portrait and landscape item listview (layout and layout-land) like here :
Item listview Layout for Portrait
Item listview Layout for Landscape
this is simulation rotate from portrait to landscape
result on portrait / not yet rotated
result after rotated landscape
Which I want after rotated
so how to solve it ?

This link helped me to solve a similar problem. I hope that it helps you too.
Android: alternate layout xml for landscape mode

Related

Android - activity with viewpager and fragments does not resume the portrait layout when rotating the device. Only on Huawei smartphones

Introduction
I'am facing a strange problem that is happening only on the new device I am trying: Huawei P8.
I can't put a screenshot of what is happening but I will try to summarize as follow:
The activity has only one layout in folder "layout"
Some of the fragments that compose the viewpager have both "layout" and "layout-land" layouts for different views depending on the rotation of the device.
Problem
Starting the activity in portrait everything works and the fragments have their portrait layout
Rotating to landscape makes the fragments switch to their landscape layout (if the fragment has its custom landscape layout draws it) correctly
When rotating back to portrait the problem appears. The fragments that have a specific landscape layout does not switch back to portrait layout keeping the landscape one and the result is:
With the device in portrait the layout is drawn with landscape layout (took from layout-land) which is very bad to see because every view is compressed/stretched unnaturally.
I have tried many smartphones in the years and this only happens on Huawei P8 (Android 5.0)
Hm. A long time ago I have a similar problem. It was happens due to firmware problems. What I did? I download Application that switch rotation by volume-up key. That help me to get understanding - where the problem is - in my code, or this is a firmware mistake.

Android: Is that possible to mix portrait and landscape in viewpager?

I have a question about viewpager.
Is that possible to mix portrait and landscape orientation in one viewpager?
To be specific, some of the pages are in portrait orientation while other pages are in landscape orientation.
Thanks.
you can override the method getWidth(int) from the adapter to change the width of each page and with that, changing their proportions.

why are my buttons not fitting properly?

In landscape mode they properly stretch to fit the width..but in portrait the Exit button is extending too far to the right.
layout code: http://pastebin.com/KZVCdVJw
The reason why it wasnt properly fitting the screen was due to the orientation of the LinearLayout it was in. By changing the orientation from horizontal to vertical it solved the problem.

Force orientation depending on the View inside ViewFlipper

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

how to add scrollview to screen in android?

I have done my application in portrait configaration but when load my application in to device its coming portraint configaration but I keep in landscape mode missing some controls. So I want to add scroll view to screen when changing the config to landscape. How I can add ScrollView to screen ?
You could define two version of your layout.
"res/layout/your_layout.xml" - this will be used in portrait mode
"res/layout-land/your_layout.xml" - android will use this when in landscape orientation
If you don't want to do to many changes in your layout you can add ScrollView to landscape version of your_layout.xml.
Regards!

Categories

Resources