HorizontalScrollView を使ってみた

横方向にスクロールさせるには
HorizontalScrollView を使います
java.lang.Object
  ↳ android.view.View
    ↳ android.view.ViewGroup
      ↳ android.widget.FrameLayout
        ↳ android.widget.HorizontalScrollView

その名の通り ScrollView の横バージョンです

HorizontalScrollView は ScrollView と同様一つしか子ビューを持てないので
LineaLayout などにまとめて入れてやります

というわけで, HorizontalScrollView をいじってみた

XMLリソース
  1. <HorizontalScrollView  
  2.   android:layout_width="fill_parent"  
  3.   android:layout_height="fill_parent"   
  4.   android:id="@+id/HorizontalScrollView">  
  5.   <LinearLayout   
  6.     android:id="@+id/LinearLayout"  
  7.     android:layout_width="wrap_content"   
  8.     android:layout_height="wrap_content">  
  9.     <TextView   
  10.       android:id="@+id/TextView"   
  11.       android:layout_width="wrap_content"  
  12.       android:layout_height="wrap_content"   
  13.       android:text="HorizontalScrollViewTest">  
  14.     </TextView>  
  15.         ・  
  16.         ・  
  17.         ・  
  18.   </LinearLayout>  
  19. </HorizontalScrollView>  
アクティビティー側で setContentView で設定

プログラムを実行すると...


こんな感じ!

一番下にスクロールバーが表示されています

参考サイト
http://developer.android.com/intl/ja/reference/android/widget/HorizontalScrollView.html

0 件のコメント:

コメントを投稿