首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >有什么方法可以去除ImageButtons中的灰色背景吗?

有什么方法可以去除ImageButtons中的灰色背景吗?
EN

Stack Overflow用户
提问于 2012-03-02 10:48:35
回答 11查看 28.8K关注 0票数 27

我有一个ImageButton和我想删除丑陋(IMHO)的背景,周围的图像。我可以只添加一个ImageView,但它们很难完美地设置在如图所示的灰色布局中。[重力“中心”不会使它居中,只是垂直居中。)

那么有什么方法可以去掉它吗?

EN

回答 11

Stack Overflow用户

回答已采纳

发布于 2012-03-02 11:26:38

只需使用android:background="#0000" (#0000与#00000000相同)或

ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundDrawable(null);
票数 45
EN

Stack Overflow用户

发布于 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"
/>
票数 30
EN

Stack Overflow用户

发布于 2016-12-08 21:59:36

您可以保留方形框,只需更改其颜色,如下所示:

android:backgroundTint="@color/colorPrimary"

效果很好

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9527288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档