Mouley Mouley - 9 days ago 5
Android Question

android ImageView doesn't show transparency

I got a png image with as transparent color, white one which i want to use in an ImageView for an android app.
You can check that the image has a transparency color

I added the picture to each of the folders (drawable-mdpi, drawable-ldpi..)
and linked the ImageView with the image.
Instead of getting a transparency color, i got a white one as shown below
The result
The blue screen is a RelativeLayout with background.
Here's the XML code:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/barre_puissance"
android:layout_toRightOf="@+id/barre_angle"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/bg_mr">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_mr_projectile"
android:layout_centerInParent="true"
/>
</RelativeLayout>

Answer

Android XML Supports transparency with png files so problem has be with your image. Make sure your png image file is contain transparency.

Comments