您可以使用对象的android:foreground
属性设置在任何物体的颜色。这里我用了一个ImageView
来显示图像,并android:foreground
把过滤!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/yourImage"
android:foreground="#60000000" />
</RelativeLayout>
,如果你想这样做的布局,然后使用Android:背景属性,而不是android:src
图像的来源。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/yourImage"
android:foreground="#60000000">
</RelativeLayout>
图像有背景和src属性或使用ColorFilter –
可能重复[在85%不透明度的Android黑色](http://stackoverflow.com/questions/6024867/android-black-color-at-85-opacity ) –
不透明度看到这 - http://stackoverflow.com/a/17239853/7235539 –