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 foreground.

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"/>

When you use set only foreground by using android:src propery

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

When you set only Background using android:background property

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top