レイアウト例(フレーム数3) … 縦一列

Android用語集

カテゴリー: ViewGroupクラス  閲覧数:390 配信日:2014-05-05 07:49




構成


LinearLayout大枠
 ┃
 ┣FrameLayout
 ┃ └TextView
 ┃ 
 ┣FrameLayout
 ┃ └ImageView
 ┃
 ┗FrameLayout
   └ImageView

・3つのFrameLayout
フレーム構成 ビュー名称
FrameLayout TextView
FrameLayout ImageView
FrameLayout ImageView


コード


▼/res/layout/activity_main.xml
<LinearLayout 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"
   android:orientation="vertical"
   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">
   <FrameLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content">
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="@string/hello_world"/>
   </FrameLayout>
   <FrameLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content">
       <ImageView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/ic_launcher"/>
   </FrameLayout>

   <FrameLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
       <ImageView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/ic_launcher"/>
   </FrameLayout>
</LinearLayout>

▼/res/values/strings.xml
<string name="hello_world">Hello world! My name is Android.</string>