2011-12-22 148 views
0

是否有可能(任何可能的,正確的!)在一個佈局屏幕上創建雙水平滾動視圖?Android佈局 - 雙水平滾動視圖

作爲一個例子....我想兩個(或三個)行或獨立滾動的圖標。我在Pulse等應用中看到了這種類型的行爲。

幫助與佈局代碼請...這是我的單一hor。滾動...

<?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>