我有一个这样的按钮...
抱歉,如果它看起来很暗,但如您所见,我已经设置了高度和宽度来包裹内容,但 scaletype 不是 fitxy,所以如果您愿意的话,仍然存在“按钮过多”。
有什么办法可以去掉吗?
最佳答案
您可以使用 ImageButton。在你的 xml 中做
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonSettings"
android:src="@drawable/tabbar_icon"
android:background="@android:color/transparent"/>
或以编程方式。这很简单,只需将背景颜色设置为透明
ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01);
btn.setBackgroundColor(Color.TRANSPARENT);
关于android - 是否可以使按钮的背景透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21427343/