In the YouTube android app, when you search for videos there is a ListView
that displays the video results, 1 item per row:
When you rotate your phone into landscape mode, the ListView
displays 2 items per row:
How can I achieve that in my app?
In the YouTube android app, when you search for videos there is a ListView
that displays the video results, 1 item per row:
When you rotate your phone into landscape mode, the ListView
displays 2 items per row:
How can I achieve that in my app?
I guess you've got your solution by now, but for others, here is maybe a solution :
try to use a GridView
with android:numColumns="1"
or 2
depending of the screen orientation.
That depends,
1) You can use GridView, it will automatically fill the space in landscape if you'r view's are smaller. If you want exactly 2, you need to set width of your view, exactly as half of screen width in landscape mode. Or go for option 2
2) You can use different adapters. Portrait adapter is usual. Landscape adapter return getCount twice smaller , and in view creation method create this cell with 2 items, using LinearLayout and it's children width weight = 1 and layout_width = 0