Is it possible to define a different multi-column approach for a list view in portrait and landscape? For example on the Android market you have two columns when scrolling through apps in portrait mode but 3 columns in landscape.
I couldn't see a way of defining two "positions" within one layout row in the custom adapters and no way of specifying that the ListView has two different list items within one row. Should I be using a different sort of layout?
If you add the two folders :
layout-land
layout-port
In each of these folders there is the same file, say myRowLayout.xml
When your device is in landscape mode, myRowLayout.xml
that is in the folder layout-land
will be used, while that in layout-port
will be used when in portrait mode.
The Market App is not using a ListView it is using a GridView see the Hello GridViewTutorial for more info.
A GridView can use the same Adapter as a listview but it will position items in a grid with multiple columns. You could either specify the number of columns in a ressource file and then distinguish with values-port values-xhdpi etc. or you can make the GridView to choose for itself how many columns should be shown.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.