[英]Relative Layout Android put one image on top of another
I want the image that I use as a button to appear above the large image but I don't know how to do it.我希望用作按钮的图像出现在大图像上方,但我不知道该怎么做。 Could you help me?
你可以帮帮我吗?
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/details_nombre_ofi"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/button1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="24dp"
android:layout_marginTop="16dp"
android:background="@drawable/flecha" />
<ImageView
android:id="@+id/details_imagen_of"
android:layout_width="match_parent"
android:layout_height="220dp"
android:contentDescription="TODO"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</ImageView>
here is the image, I want the square to be seen above这是图像,我希望在上面看到正方形
You can use of this property in your XML file:您可以在 XML 文件中使用此属性:
android:layout_above="@+id/YOUR_VIEW_ID"
"i'm just change Relative to Linear and make orientation vertical. that what you want i think"
“我只是改变相对于线性并使方向垂直。我想你想要什么”
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:text="Button"/>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="220dp"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/ic_launcher_background"
app:layout_constraintTop_toTopOf="parent">
</ImageView>
</LinearLayout>
"copie and paste this code on your xml" "note: if you want use Relative layout add
android:layout_above=""
to ImageView or Button ""复制并粘贴此代码到您的 xml" "注意:如果您想使用相对布局添加
android:layout_above=""
到 ImageView 或按钮 "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.