2011-12-22 2 views
0

Возможно ли (все возможно, правильно!) Создавать двойные горизонтальные прокрутки на одном экране макета?Android Layout - Двойной горизонтальный вид прокрутки

В качестве примера .... Я хотел бы, чтобы две (или три) строки или значки прокручивались независимо. Я вижу этот тип поведения в таких приложениях, как Pulse.

Помогите с оформлением кода пожалуйста ... вот мой единственный круг. свиток ...

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

     <HorizontalScrollView android:layout_height="100dp" > 

      <ImageButton 
       android:id="@+id/ImageButton1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/icon1" > 
      </ImageButton> 

      <ImageButton 
       android:id="@+id/ImageButton2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/icon2" > 
      </ImageButton> 
     </HorizontalScrollView> 

     <HorizontalScrollView android:layout_height="100dp" > 

      <ImageButton 
       android:id="@+id/ImageButton3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/icon3" > 
      </ImageButton> 

      <ImageButton 
       android:id="@+id/ImageButton3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/icon4" > 
      </ImageButton> 
     </HorizontalScrollView> 

    </LinearLayout> 

** * * Обновлен код по-прежнему не работает ... Может быть, высота/ширина свойства?

ответ

2

Здесь решение это работает отлично

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <HorizontalScrollView 
     android:layout_height="100dp" 
     android:layout_width="100dp"> 
     <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"> 
     <ImageButton 
      android:id="@+id/ImageButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" > 
     </ImageButton> 

     <ImageButton 
      android:id="@+id/ImageButton2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" > 
     </ImageButton> 
     </LinearLayout> 
    </HorizontalScrollView> 

    <HorizontalScrollView android:layout_height="100dp" 
     android:layout_width="100dp" > 
     <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"> 

      <ImageButton 
       android:id="@+id/ImageButton3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" /> 

     <ImageButton 
      android:id="@+id/ImageButton3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" > 
     </ImageButton> 
     </LinearLayout> 
    </HorizontalScrollView> 

</LinearLayout> 

попробовать это удовольствие ...

0

Просто поместите два или более свитков в одном LinearLayout

<LinearLayout 
     android:orientation="vertical" ...> 
    <HorizontalScrollView android:layout_height="100dp" .../> 
    <HorizontalScrollView android:layout_height="100dp" .../> 
    ... 
</LinearLayout> 
Смежные вопросы