2

In the YouTube android app, when you search for videos there is a ListView that displays the video results, 1 item per row:

enter image description here

When you rotate your phone into landscape mode, the ListView displays 2 items per row:

enter image description here

How can I achieve that in my app?

Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288

2 Answers2

2

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.

Google guide

Defoncesko
  • 657
  • 5
  • 25
1

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

logcat
  • 3,435
  • 1
  • 29
  • 44