0

I have an Image View in my layout and android:background isn't working in Android 2.3.6 and below.
It works perfectly in newer versions.

Here is the code:

<ImageView
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:alpha="0.5"
     android:background="#000000" />

It is also inside 2 Frame Layouts but I don't think this will help solving the issue because every child shows perfectly, except this Image View. I'll post the code if you want.

Any ideas?

Thanks in advance

Erick Filho
  • 1,962
  • 3
  • 18
  • 31
  • check this [link](http://stackoverflow.com/questions/7378636/setting-background-colour-of-android-layout-element) and try it.. – Lal May 05 '14 at 14:52
  • Have you tried "#ff000000" to ensure full alpha? – Neil Townsend May 05 '14 at 15:00
  • Ok @ErickFilho and please do tell me the result.. – Lal May 05 '14 at 15:46
  • @NeilTownsend No, I didn't think it could be related to alpha because in my mind, if alpha wasn't supported, it should be ignored and my imageview background shouldn't be affected. – Erick Filho May 05 '14 at 15:46
  • @ErickFilho Whilst in principle I agree with you, my personal experience with TextViews (eg. http://stackoverflow.com/questions/16491280/how-often-can-you-update-a-textview-without-mess/16497426#16497426) has led me to make my code pretty explicit about many "theoretically irrelevant" things with them. – Neil Townsend May 06 '14 at 07:45

1 Answers1

2

View.setAlpha was introduced in API Level 11. You can change also the alpha through the background property. From the doc

May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

android:background="#7A000000"
Blackbelt
  • 156,034
  • 29
  • 297
  • 305