レイアウト例

Android用語集

カテゴリー: ScrollViewクラス  閲覧数:317 配信日:2018-07-04 04:27




構成


・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>