プログラミング言語や環境設定を中心としたパソコン関連の技術メモです。
主にシステム開発中に調べたことをメモしています。TIPS的な位置付けで、気が向いたときにちまちま更新していきます。
Java(Android)、スクロールバーを使用する-スクロールバーあれこれ(1)
今回はレイアウト用XMLのお話です。
まずは一番基本部分、スクロールバーってどーやって使うの(--?なところ。
ひと言で言えばスクロールさせたい場所を囲ってやれば良いのです。

横スクロールバーは例えばこんな感じφ(--)

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

  <LinearLayout android:id="@+id/linearLayout2"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
  >

    ~うんちゃらかんちゃら~

  </LinearLayout>

 </HorizontalScrollView>

「<HorizontalScrollView>~</HorizontalScrollView>」ですね。
ポイントは「<LinearLayout>~</LinearLayout>」。
「<HorizontalScrollView>~</HorizontalScrollView>」の間に
複数要素置こうとすると怒られてしまいます。
一旦「<LinearLayout>~</LinearLayout>」等を置いて
その中でボタンとかテキストとかを配置したってください。

縦スクロールバーは例えばこんな感じφ(--)

 <ScrollView
  android:id="@+id/scrollView1"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  >

  <LinearLayout android:id="@+id/linearLayout2"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
  >

    ~うんちゃらかんちゃら~

  </LinearLayout>

 </ScrollView>

「<ScrollView>~</ScrollView>」ですね。
あとは横スクロールバーと同じです。
スポンサーリンク
 
このエントリーをはてなブックマークに追加 

category:Android  thema:プログラミング - genre:コンピュータ  Posted by ササキマコト 

  関連記事