ScrollViewクラス

ViewクラスScrollViewクラス

ScrollViewクラスとは?

 状態:-  閲覧数:1,656  投稿日:2014-07-08  更新日:2018-07-04  

スクロール表示


画面にレイアウトが収まらない場合、収まらない分をスクロールして表示するためのクラス

構成

 閲覧数:384 投稿日:2014-07-09 更新日:2018-07-04 
java.lang.Object
  ↳ android.view.View
     ↳ android.view.ViewGroup
        ↳ android.widget.FrameLayout
           ↳ android.widget.ScrollView


レイアウト例

 閲覧数:331 投稿日:2018-07-04 更新日:2018-07-04 


構成


・1つのScrollViewの中に、1つのRelativeLayoutを配置

ScrollView
 ┗RelativeLayout
   │├android:layout_width="match_parent"
   │├android:layout_height="wrap_content"
   │├android:paddingBottom="@dimen/activity_vertical_margin"
   │├android:paddingLeft="@dimen/activity_horizontal_margin"
   │├android:paddingRight="@dimen/activity_horizontal_margin"
   │└android:paddingTop="@dimen/activity_vertical_margin"
   │
   ├TextView
   │ ├android:id="@+id/LongText"
   │ ├android:layout_width="match_parent"
   │ ├android:layout_height="wrap_content"
   │ └android:text="@string/hello_world"
   │  
   └Button
    ├android:layout_width="match_parent"
    ├android:layout_height="wrap_content"
    ├android:layout_below="@+id/LongText" … LongTextで指定した文字列の下
    └android:text="Button"


コード


▼/res/layout/activity_main.xml
<ScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:paddingBottom="@dimen/activity_vertical_margin"
       android:paddingLeft="@dimen/activity_horizontal_margin"
       android:paddingRight="@dimen/activity_horizontal_margin"
       android:paddingTop="@dimen/activity_vertical_margin"
       tools:context=".MainActivity">
       <!-- TODO: LongText をスクロールできるようにする -->
       <!-- TODO: LongText の下に 1 つ Button を配置する -->
       <TextView
           android:id="@+id/LongText"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="@string/hello_world"/>
       <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_below="@+id/LongText"
           android:text="Button"/>
   </RelativeLayout>
</ScrollView>


▼/res/values/dimens.xml
<resources>

   <!-- Default screen margins, per the Android Design guidelines. -->
   <dimen name="activity_horizontal_margin">16dp</dimen>
   <dimen name="activity_vertical_margin">16dp</dimen>

</resources>


▼/res/values/strings.xml
<string name="hello_world">Hello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \nHello world! My name is Android. This app is written in Java, and running on Dalvik VM, not Sun VM. Nice to see you! Have fun \n</string>



コメント投稿(ログインが必要)