自发布之后已经有一段时间了,但这对我有帮助。
您可以使用嵌套布局。从一个RelativeLayout开始,并把你的ImageView。
将高度和宽度设置为match_parent以填充屏幕。
设置scaleType =“centreCrop”,使图像适合屏幕,不拉伸。
然后,您可以像平常一样放置任何其他布局,如下面的LinearLayout。
您可以使用android:alpha来设置图像的透明度。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/image"
android:alpha="0.6"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="There"/>
</LinearLayout>
</RelativeLayout>
不要相信这适用于背景,但它应该适用于图像。 'android:scaleType =“centerCrop”' – EGHDK 2013-04-21 20:59:42
详细的博客:http://sforsuresh.in/set-background-image-android-xml/ – 2017-07-20 08:51:53