1

I'm having issues with color resources in Android, specifically using a transparent color.

Any time I use my transparent color from the colors resources, the background of the View shows up as a red gradient instead when previewed in the emulator (tested versions 1.6, 2.2 and 2.3 on AVDs) or on a device (DroidX w/ 2.3.4). The transparent color is displayed correctly (or rather, is not) in the preview mode in Eclipse.

As far as I can tell, this particular gradient isn't defined anywhere in my application. The title bar does use a red gradient from an xml shape resource, but it's completely different shades of red. There is also a very simple custom styles definition, but it only sets the window title background and text colors.

My color definition:

<color name="transparent">#0000</color>  <!--Tried #00000000 as well // -->

An example View exhibiting the issue:

<Button
    android:id="@+id/btn_login"
    android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:layout_marginRight="10dp"
    android:text="@string/ui_btn_login" android:textColor="@color/dark_grey"
    android:background="@color/transparent"
    android:drawableTop="@drawable/ic_login" android:drawablePadding="2dp" />

Results in the red gradient (when using the the color resource): http://i683.photobucket.com/albums/vv194/platinumF150/trans_resource.png

<Button
    android:id="@+id/btn_login"
    android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:layout_marginRight="10dp"
    android:text="@string/ui_btn_login" android:textColor="@color/dark_grey"
    android:background="#0000"
    android:drawableTop="@drawable/ic_login" android:drawablePadding="2dp" />

Results in the correct display (when using the color code inline): http://i683.photobucket.com/albums/vv194/platinumF150/trans_color.png

However when I use android:background="@android:color/transparent" everything works normally...

I'm seeing this throughout my application, any view that uses @color/transparent gets a red gradient.

Obviously its not a huge deal to just use Android's transparent color everywhere, its just frustrating, and I'm sure there is a solution. I've never seen this issue before, but I've also never used too much transparency in an app.

Thanks for any thoughts or input you might have!

Felix Christy
  • 2,179
  • 1
  • 19
  • 32

1 Answers1

0

as per

android.R.color.transparent not fully transparent

&

How to make a ListView transparent in Android?

"#00000000" should work ..........

use @android:color/transparent from transparent color instead of android:background="@color/transparent"

Community
  • 1
  • 1
Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36