【发布时间】:2016-09-27 12:16:18
【问题描述】:
【问题讨论】:
-
更改 Framelayout 中图像的顺序。您在 FrameLayout 中将图像放在最后。首先,您放置一个图像并放置其他项目。
标签: android xml android-studio overlapping android-framelayout
【问题讨论】:
标签: android xml android-studio overlapping android-framelayout
这是示例,https://snag.gy/IrawbT.jpg
最后放入堆栈的项目将被绘制在它下面的项目之上。 这种布局可以很容易地在其他布局之上绘制, 尤其适用于按钮放置等任务。
要在
FrameLayout中排列子元素,请使用android:layout_gravity属性以及任何android:paddingandroid:margin你需要。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Child1 is drawn first -->
<!-- Child2 is drawn over Child1 -->
<!-- Child3 is drawn over Child1 and Child2 -->
<TextView
android:id="@+id/child1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:text="Child 3"
android:textSize="25sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/child2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="40dip"
android:src="@color/childs"
android:text="Child 2" />
<ImageView
android:id="@+id/child3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="Image"
android:src="@color/_dark_gray" />
</FrameLayout >
【讨论】:
这是实现你想要的一种方式
<FrameLayout>
<ImageView>
<- Your background image with width and height to match parent ->
<ImageView>
<-this is where you put your image->
</FrameLayout>
【讨论】: