Androidはどのようにして2つのviewのZ orderを設定しますか?
1311 ワード
あるビューを別のビューの上に表示したい場合は、次のようにします.
You can't use a LinearLayout for this, but you can use a FrameLayout . In a
In this instance, the TextView would be drawn on top of the ImageView, along the bottom center of the image.
You can't use a LinearLayout for this, but you can use a FrameLayout . In a
FrameLayout
, the z-index is defined by the order in which the items are added, for example: <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_drawable"
android:scaleType="fitCenter"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:padding="5dp"
android:text="My Label"
/>
</FrameLayout>
In this instance, the TextView would be drawn on top of the ImageView, along the bottom center of the image.