ウェブアプリケーション,インジェクション,コマンドインジェクション

Androidアプリ開発 Viewをつかったインターフェースデザイン

Viewの部品 スクロールViewを使う

Using the ScrollView

ScrollViewはFrameLayoutの特別な型で、
デバイスの画面サイズを越えて配置されているViewのリストを
使ってユーザにスクロール可能にします。
ScrollViewは1つのChild ViewやViewグループにだけ含まれ、
通常はLinearLayoutです。
ここでは、ScrollViewの使い方を示します。
activity_main.xmlファイルに以下のようなコード部があるとします。

<ScrollView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   xmlns:android="http://schemas.android.com/apk/res/android" >

   <linearLayout
     android:layout_width="metch_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical" >

     <Button
       android:id="@+id/button1"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="Button 1" />

     <Button
       android:id="@+id/button2"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="Button 2" />

     <Button
       android:id="@+id/button3"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="Button 3" />

    EditText
       android:id="@+id.txt"
       android:layout_width="match_parent"
       android:layout_height="600px" />


     <Button
       android:id="@+id/button4"
       android:layout_width="match_parent"
      &emsp:android:layout_height="wrap_content"
       android:text="Button 4" />
以下同じ様にボタン10くらいまで作るとスクロールがわかりやすいです。
   <LinearLayout>
<ScrollView>

上のコードをAndroidエミュレータでロードしてみると、
エミュレータの画面には何も表示されません。
これはEditTextが自動的にフォーカスされるためで、
EditTextがアクティビティ全体を埋めています。
上のコードではEditTextを高さ600pxにセットしています。
フォーカスを受けない様にするためには、
<LinearLayout>に以下のような2つの属性を付け加えます。

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:focusable="true"
   android:focusableInTouchMode="True" >

上のコードを付け加えることで、EditTextからフォーカスが外れ、
ボタンが見えてきます。



ホーム
便利堂ロゴ
inserted by FC2 system