如何删除Android中按钮周围的填充? [英] How to remove padding around buttons in Android?
本文介绍了如何删除Android中按钮周围的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 Android 应用中,我有这样的布局:
In my Android app, I have this layout:
<?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>
在预览和手机上,它看起来像:
In the preview and on the phone, it looks like:
正如您在底部区域的按钮上看到的那样,那里有一些填充.
As you can see on the button in the bottom area, there is some padding there.
我怎样才能摆脱它,让按钮完全填满底部区域?
How can I get rid of that, and let the button fully fill the bottom area?
推荐答案
对我来说,问题出在某些 Android 主题的 minHeight 和 minWidth 上.
For me the problem turned out to be minHeight and minWidth on some of the Android themes.
在 Button 元素上,添加:
On the Button element, add:
<Button android:minHeight="0dp" android:minWidth="0dp" ...
或者在您的按钮样式中:
Or in your button's style:
<item name="android:minHeight">0dp</item>
<item name="android:minWidth">0dp</item>
这篇关于如何删除Android中按钮周围的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文