Android的布局背景Alpha [英] Android Layout background alpha
本文介绍了Android的布局背景Alpha的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有我正在使用,以填补我的网页布局,我必须设置在我的绘制文件夹
在布局召开的背景图像。
Hi I have a layout which I'm using to fill my page and I have to set a background image held in my drawable folder
in that layout.
我要接盘 alpha值
形象的东西相当低,几乎让像水标志的图像。
I want to then set the alpha value
of the image to something quite low almost make the image like a water mark.
我的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的布局
As you can see I have assigned an id to the layout
我想在我的OnCreate我可以做这样的事情?
I thought in my oncreate I could do something like this?
View backgroundimage = (View) findViewById(R.id.background);
backgroundimage.setAlpha(80);
这是不工作但我怀疑它,因为我想投背景为查看
我要抛弃它?
This is not working however I suspect its because I'm trying to cast the background as a View
what should I cast it as?
推荐答案
尝试使用 Drawable.setAlpha();
Try to use Drawable.setAlpha();
你应该做的是这样的:
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
这篇关于Android的布局背景Alpha的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文