我想创建一个透明的 ImageButton,把这些按钮都放在一个 SurfaceView 视图中,我在XML中这样设置的代码:
<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 没有创建成功,如何实现呀?
给个具体的方法:
<ImageButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/media_skip_backward" >
</ImageButton>
android:background="#ff000000"
你的背景色设成这样试试,看看是不是你想要的效果
src中的内容会覆盖在background内容之上 不过ImageButton里面包含的东西比较多 你可以只用Button或者一个View不就好了 反正都能添加onclick事件
ImageButton imb = (ImageButton) findViewById(R.id.imageButton1);
imb.setAlpha(50);