开发者

Android ImageButton: image with tranparent background

i want to write an application where the user can change the colo开发者_如何学运维r scheme. I have Imagebuttons and the images on the buttons are pngs and have transparent background. but when i place them on the buttons they are not transparent anymore. could anybody help me with some code? thanks! Anne


Are you ensuring that android:background="@null" is set? Otherwise you'll have the gray button background. For example:

<ImageButton
    android:background="@null"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/my_transparent_png"
    />


write your layout for ImageButton as:

<ImageButton
            android:src="@drawable/your_image"
            android:id="@+id/your_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"/>

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜