Setting Alpha level on view doesn't work
I am trying to set the alpha level of a view. I am reading the documentation here:
http://developer.android.com/reference/android/widget/RelativeLayout.html
and it seems as if it should be possible even on android 2.1 which I am developing for (as I cant 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 saying:
开发者_如何学PythonNo resource identifier found for attribute 'alpha' in package 'android'
How do I set the alpha level of a view?
you can set the alpha with the background properties like this way
android:background="#50ffffff"
here the first 50 value is set the alpha value
On which android version are you running this?
setAlpha is only available on api level 11. You might try some other way to do this if you want to do this in previous versions. Probably using a semi-transparent background could do it.
精彩评论