Add image button with transparent background.

I want to add image buttons on my main application screen that have a transparent background. I created images in GIMP and saved them with a transparent background in png format, but when I add them to my Android application in Eclipse, they appear on a white background. How to remove this in my code?

+6
source share
5 answers

Try using the null value for the background for the image button in the xml layout.

android:background="@null"
+11
source

A transparent background usually works when used in Photoshop, if this is not the case, you need to set the alpha bits of the pixels around the border of your image

- ( -, google, ).

: - ( ), . , 255, ( , ); - 0, (). : .

, . geral:.

  • JPEG (JPEG ). PNG

    2. , ( Google - PNG), - ( , Paint.NET ex).

  • , ( . ).

    , PNG- , -0, , original PNG with alpha blending

aplha blended PNG on colored background

- - PNG Activity. , , .

+1

android:background="@null"

XML

0

.aspx - , . , .gif, , , , IE9 Chrome, .

, , , .gif :

<asp:ImageButton runat="server" ID="lnkFavorite" BackColor="Transparent" AlternateText="Add Favorite" CommandName="Favorite"
ImageUrl="Images/MakeFavorite_30.png" ToolTip="Click to add to the My Favorite Threads grid."
    CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") + ";" + Eval("FavoriteUserID")%>' />

BackColor = "" ! , !

0

5 Android L+.

PNG () ImageButton, background src

     <ImageButton
        android:id="@+id/imageProg"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:onClick="doStuff"
        android:background="@drawable/ic_stuff"
0

All Articles