<ImageButton android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/media_skip_backward"
android:background="@drawable/transparent"></ImageButton>

这是我试图获得一个透明的ImageButton,以便将这些按钮放在SurfaceView上。但是当我在xml中包含透明行时,Eclipse会在项目中给我一个错误。

请帮助。


当前回答

最好的方法是使用透明的颜色代码

android:background="#00000000"

使用颜色代码#00000000使任何东西透明

其他回答

它的android:背景= " @android:颜色/透明”

<ImageButton
    android:id="@+id/imageButton"
    android:src="@android:drawable/ic_menu_delete"
    android:background="@android:color/transparent"
/>
<ImageButton
    android:id="@+id/previous"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/media_skip_backward">
</ImageButton>

我为ImageButton使用了一个透明的png格式,ImageButton工作正常。

尝试使用null作为背景…

android:background="@null"

它工作,也保持按钮点击的视觉反馈,

android:backgroundTintMode="screen"

你也可以使用透明的颜色:

android:background="@android:color/transparent"