目次へ
FrameLayoutでは、その中に部品を置くとその上に重なって表示されていきます。下の例は、それを使って画像の上にボタンともうひとつのが像を重ねています。
■■■■FrameLayout例
レイアウトファイル<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/img1"/ /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:src="@mipmap/ic_launcher" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="ボタン"/> </FrameLayout> |
上のような指定をした場合、次のような画面が表示されます。


にほんブログ村
0 件のコメント:
コメントを投稿