この画像のようなレイアウトをデザインしたい
Frame 1
灰色で彼Frame 2
は透明です。使う必要があると思いますが、使い方FrameLayout
がよくわかりません。
この画像のようなレイアウトをデザインしたい
Frame 1
灰色で彼Frame 2
は透明です。使う必要があると思いますが、使い方FrameLayout
がよくわかりません。
実際、 aFrameLayout
または a をRelativeLayout
(少なくとも にはFrame 1
) 使用できますが、これらのフレームで何をしたいのか正確には言いません (これにより、状況が少し変わります)。フレーム2に加えてフレーム1にコンテンツがあると推測しているため、aを使用しRelativeLayout
ます。
<RelativeLayout android:id="@+id/frame1" android:background="#c1c1c1"// other attributes>
<FrameLayout android:id="@+id/frame2" android:layout_centerInParent="true"
android:background="@android:color/transparent"// other attributes />
</RelativeLayout>
2つのフレームを使用して上記のような画面を作成することはできません.1つのフレームを別のフレームレイアウトに配置することはできないため、別の方法を使用して作成することができます.1つの相対レイアウトを取得し、その中にフレームを配置する. 、
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black" >
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="250dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="180dp"
android:background="@color/tbl_green">
</FrameLayout>
</RelativeLayout>
これはあなたを助けることができるかもしれません。
1つの方法は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#c0c0c0" >
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="#ffffff"
android:gravity="center" >
</LinearLayout>
</RelativeLayout>