首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Android中删除按钮周围的填充?

如何在Android中删除按钮周围的填充?
EN

Stack Overflow用户
提问于 2013-07-31 10:27:08
回答 16查看 143.6K关注 0票数 230

在我的Android应用程序中,我有这样的布局:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8" ?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical">

    <fragment
         android:id="@+id/map"
         android:layout_width="match_parent"
         android:layout_height="0dp" 
         android:layout_weight="1" 
         class="com.google.android.gms.maps.SupportMapFragment"/>

    <Button
        android:id="@+id/button_back"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:onClick="CloseActivity"
        android:padding="0dp"
        android:text="@+string/back" />

</LinearLayout>

在预览和电话中,它看起来是这样的:

正如你在底部区域的按钮上所看到的,那里有一些填充。

我怎么才能去掉它,让按钮完全填满底部区域呢?

EN

回答 16

Stack Overflow用户

回答已采纳

发布于 2013-12-02 16:24:49

对我来说,问题是一些安卓主题上的minHeight和minWidth。

在Button元素上,添加:

代码语言:javascript
运行
复制
<Button android:minHeight="0dp" android:minWidth="0dp" ...

或者使用您的按钮的样式:

代码语言:javascript
运行
复制
<item name="android:minHeight">0dp</item>
<item name="android:minWidth">0dp</item>
票数 524
EN

Stack Overflow用户

发布于 2019-09-25 18:41:25

我的解决方案是将insetTop和insetBottom属性设置为0。

代码语言:javascript
运行
复制
<android.support.design.button.MaterialButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:insetTop="0dp"
        android:insetBottom="0dp"
        android:text="@string/view_video"
        android:textColor="@color/white"/>
票数 154
EN

Stack Overflow用户

发布于 2013-07-31 10:30:19

这不是填充,而是背景可绘制按钮周围的阴影。创建你自己的背景,它就会消失。

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

https://stackoverflow.com/questions/17960599

复制
相关文章

相似问题

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