如何在Android中移除填充按钮周围?移除、按钮、如何在、Android

2023-09-05 07:03:52 作者:苦瓜一样甜

在我的Andr​​oid应用程序,我有这样的布局:

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>

而preVIEW和手机上的样子:

And the preview and on the phone looks like:

正如你可以在底部按钮看到,有一些填充那里。

As you can see on the bottom button, there is some padding there.

我怎样才能摆脱这一点,让按钮完全填满底部区域?

How can I get rid of that, and let the button fully fill the bottom area?

感谢

推荐答案

有关我的问题竟然是和了minHeight上了minWidth一些Android的主题。

For me the problem turned out to be minHeight and minWidth on some of the Android themes.

按钮元素中,添加:

<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>