Setting the alpha level to the view does not work

I am trying to set the alpha level of a view. I read the documentation here:

http://developer.android.com/reference/android/widget/RelativeLayout.html

and it seems like it should be possible even for android 2.1, for which I am developing (since I cannot see it saying otherwise), but when I add it to my view

<View android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="20sp" android:background="#ffffff" android:alpha="0.9"></View> 

I get an error message:

Resource ID found for attribute 'alpha' in package 'Android'

How to set alpha level of representation?

+7
source share
2 answers

you can set alpha with background properties like this path

 android:background="#50ffffff" 

here in the first value of 50 the alpha value is set

+12
source

What version of Android are you running this on?

setAlpha is only available at api level 11. You can try a different way to do this if you want to do this in previous versions. Perhaps using a translucent background could do this.

+2
source

All Articles