2012-11-24 9 views
5
<GridView 
android:id="@+id/gridView1" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:columnWidth="100dip" 
android:numColumns="8" 
android:scrollbarStyle="insideOverlay" 
android:scrollbars="vertical|horizontal" 
android:stretchMode="none" > 
</GridView> 

私は上記のように、gridviewで垂直スクロールバーと水平スクロールバーの両方を使用します。 私は垂直のものがうまくいくのを見ましたが、水平のものはうまくいきません。 はので、私はアンドロイドのgridviewの水平スクロールバーはどのように使用できますか?

<HorizontalScrollView 
     android:id="@+id/horizontalScrollView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <GridView 
      android:id="@+id/gridView1" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:columnWidth="100dip" 
      android:numColumns="8" 
      android:scrollbarStyle="insideOverlay" 
      android:scrollbars="vertical|horizontal" 
      android:stretchMode="none" > 
     </GridView> 

    </HorizontalScrollView> 

さらに悪化以下などの水平スクロールビューの下のGridViewを配置することによって、それを修正しようとした、それは、GridViewののちょうど1列を表示し、もちろん、何の水平スクロールバーはありません。

どうすれば修正できますか?

+2

に。水平と垂直の両方scroolviewを使用するために最適なソリューション。 'GridView'を' Horizo​​ntalScrollView'の中に置くことは、 'GridView'を囲む無限のスペースを効果的に与え、スクロールバーを持たないので問題を解決しません。 – Squonk

答えて

0

クラスです。本質的に、グリッドビューは、行に加えて列をサポートするリストビューです。したがって、水平スクロールをサポートしていません。

本質的にandroid:scrollbars="vertical|horizontal"属性を設定して行ったことは、水平線と垂直スクロールバーの両方を表示するようグリッドビューに指示することです。この属性を設定しても、ビュー内のスクロールは有効になりません(グリッドビューとリストビューでは本質的にスクロールが有効になります)。

あなたがしようとしていることについてもう少し説明できれば、別の方法を提案することができます。

0

私の知る限り、 `GridView`が画面の幅に固定されているので、それが水平方向にスクロールすることはできません知っているようアンドロイド

 <HorizontalScrollView 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@+id/seatLegendLayout"> 

      <FrameLayout 
       android:layout_width="fill_parent" 
       android:layout_height="match_parent"> 

       <LinearLayout 
        android:id="@+id/linearLayout_gridtableLayout" 
        android:layout_width="900dp" 
        android:layout_height="match_parent" 
        android:orientation="horizontal"> 

        <GridView 
         android:id="@+id/gridView1" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:layout_margin="4dp" 
         android:columnWidth="100dp" 
         android:gravity="center" 
         android:numColumns="9" 
         android:horizontalSpacing="1dp" 
         android:scrollbarAlwaysDrawHorizontalTrack="true" 
         android:scrollbarAlwaysDrawVerticalTrack="true" 
         android:scrollbars="horizontal" 
         android:stretchMode="none" 
         android:verticalSpacing="1dp"> 

        </GridView> 


       </LinearLayout> 
      </FrameLayout> 
     </HorizontalScrollView> 
関連する問題