机器人的ImageButton得到灰色背景 [英] android ImageButton gets gray background

查看:399
本文介绍了机器人的ImageButton得到灰色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个漂亮的背景选择一个按钮。精细。在按钮上的文字代替,我想要的图像。我已经试过它只是改变与src属性的ImageButton的。当我做到这一点,它看起来像一个灰色的背景上覆盖我的选择背后,在src形象背后。

i have a Button with a nice background selector. fine. in stead of text in the button, i want an image. i have tried just changing it to an ImageButton with a src attribute. when i do this, it looks like a gray background is overlaid behind my selector, behind the src image.

当我变回一个普通按钮,问题消失。我想要的只是我的背景选择,再加上SRC图像(在按钮上的文字代替)。

when i change back to a regular Button, the problem goes away. what i want is just my background selector, plus the src image (in stead of the button text).

什么想法?

推荐答案

的ImageButton应有的android:背景设定

ImageButton should have android:background set.

<ImageButton 
    android:id="@+id/ibArrow"
    android:layout_width="35px"
    android:layout_height="50px"
    android:src="@drawable/arrow"
    android:background="@drawable/backgroundstate" />   

和backgroundstate:

And backgroundstate:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_selected="true" android:drawable="@color/transparent" />
        <item android:state_pressed="true" android:drawable="@color/transparent" />
    <item android:drawable="@color/transparent" />
   </selector>

这篇关于机器人的ImageButton得到灰色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆