我有一个ImageButton和我想删除丑陋(IMHO)的背景,周围的图像。我可以只添加一个ImageView,但它们很难完美地设置在如图所示的灰色布局中。[重力“中心”不会使它居中,只是垂直居中。)
那么有什么方法可以去掉它吗?
发布于 2012-03-02 11:26:38
只需使用android:background="#0000"
(#0000与#00000000相同)或
ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundDrawable(null);
发布于 2012-03-02 11:14:22
默认背景不是透明的。
所以,只需添加透明的颜色"#00000000“作为你的背景,然后你就可以解决它。
附注:#00000000为透明色
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:background="#00000000"
/>
发布于 2016-12-08 21:59:36
您可以保留方形框,只需更改其颜色,如下所示:
android:backgroundTint="@color/colorPrimary"
效果很好
https://stackoverflow.com/questions/9527288
复制相似问题