android-widget - 在Android中的图像按钮上设置前景图像

标签 android-widget android android-imageview android-button

我正在尝试在我的图像按钮上设置前景图像。这样,按钮灰色背景可见,图像出现在前景中。

如果有任何想法,我将不胜感激。

谢谢

最佳答案

如果您想在设置前景图像时移除灰色背景,请设置一个空的背景图像。 或者只需将背景图像设置为按钮而不是设置前景图像。 我希望这能帮到您。

用代码编辑

<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

关于android-widget - 在Android中的图像按钮上设置前景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7319292/

相关文章:

android - 允许用户在 Android 应用程序中插入图像

java - 更新 Android 中的多个应用程序小部件

android - 当从它的 child 那里请求无效时,画廊上的奇怪动画

java - Android ImageView 不会清除

android - 关于 Android 中 Alarm Manager 的问题

Android从VideoView获取视频源路径

android - 想要在 android NDK 中使用系统调用运行脚本文件

Android:仅在首次运行和每次后续升级时执行代码

android - 从另一个类调用微调器给出异常

android - GridView 第一次没有被点击