【发布时间】:2023-03-17 22:45:02
【问题描述】:
如何解决此错误。基本上,图像与文本重叠。 我们可以在 XML 中解决这个问题吗?
这是代码(当然,它不完整)。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCC0000"
>
<TextView
android:background="#55000000"
android:id="@+id/centerButton"
android:text="RELATIVE LAYOUT RULES!"
android:textSize="33dp"
android:textColor="#FFFFFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<Button
android:layout_margin="40dp"
android:padding="20dp"
android:layout_below="@+id/centerButton"
android:layout_centerInParent="true"
android:text="PUSH ME!"
android:textSize="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button4" />
<ImageView
android:scaleType="centerInside"
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/Cat"
android:layout_above="@+id/centerButton"
android:layout_alignParentStart="true"
android:layout_marginBottom="39dp" />
</RelativeLayout>
【问题讨论】:
-
@Xedon 你能分享@drawable/Cat image
-
看起来你的 textview 在 imageview 后面。尝试将 textview 代码放在 xml 中的 imageview 下面。这会将文本视图带到图像的前面
-
我试过你分享的布局。有用。不是你的预览需要刷新吗?在实际设备上如何显示?