开发者

set foreground image on image button in Android

开发者 https://www.devze.com 2023-04-03 12:10 出处:网络
I am trying to set a foreground image on my image button. This way, the button gray background is visible with the image appearing in the f开发者_运维技巧oreground.

I am trying to set a foreground image on my image button. This way, the button gray background is visible with the image appearing in the f开发者_运维技巧oreground.

I would appreciate any thoughts, please.

Thanks


If you want to remove that gray background while you set foreground image then set an empty Background image. or Simply instead of setting foreground image set only background image to button. I hope this will help you.

Edited with code

<ImageButton android:text="Button" android:id="@+id/button1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:src="@drawable/icon"/>

set foreground image on image button in Android

<ImageButton android:text="Button" android:id="@+id/button1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="@drawable/icon"/>

set foreground image on image button in Android


Only use the button instead imagebutton. And in xml use the android:background="@drawable/yourdrawablewhichyouwanttoshow" hope it helps!

0

精彩评论

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