2011-12-22 256 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>