嗨,我有一个布局,用于填充我的页面,并且我必须在该布局中设置保存在我的“drawable文件夹”中的背景图像。
然后,我想将图像的alpha值设置为相当低,几乎使图像像水印一样。
我的xml如下所示
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/main_background" >
正如你所看到的,我给布局分配了一个id
我想在我的oncreate方法中能这样做?
View backgroundimage = (View) findViewById(R.id.background);
backgroundimage.setAlpha(80);
这不起作用,然而我怀疑是因为我试图将背景转换为View
,应该转换成什么?
setAlpha()
方法时,它的参数带有范围注释:@IntRange(from=0,to=255) int alpha
。 - Micer