【发布时间】:2019-08-21 00:35:37
【问题描述】:
我有一个 imageview,我想放置一个按钮来关闭/删除 imageView 中的图像,就像在 Tinder 个人资料图片上所做的那样。问题是不管我做什么,它总是放在它后面。
我有一个 RelativeLayout 作为 imageview 和 imagebutton 的容器
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="@+id/close1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_close"
android:background="@color/white"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" />
<ImageView
android:id="@+id/photo1"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginHorizontal="5dp"
android:background="@drawable/rounded_rect_primary"
android:elevation="5dp"
android:scaleType="fitXY"
android:src="@drawable/icon_upload" />
</RelativeLayout>
我也尝试过这样的事情:
close1.bringToFront();
close2.bringToFront();
close3.bringToFront();
我想了解它是如何工作的,究竟是什么定义了前面和后面的内容?
【问题讨论】:
-
您可以为此使用 FrameLayout。看看stackoverflow.com/questions/4182486/…
-
我想通了。问题是 imageview 有高度,而 imagebutton 没有。我只是简单地向 imagebutton 添加比 imageview 更高的高度
-
@ALEXANDRECHAGASVIIRAJUNIOR 如果你想通了,你可以发布你的答案,这样你的问题就不会一直没有答案。
标签: android imageview imagebutton