我已经为按钮设置了0 dp的余量,但它对顶部,底部,左边和右边的小边距没有影响,我该如何删除?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:orientation="vertical"
tools:context="com.myapp.mainpackage.MapActivity">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/mapFragment"
android:layout_width="match_parent"
android:layout_height="550dp"/>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/button4"
android:layout_margin="0dp"/>
</LinearLayout>
我无法移除按钮边距上的空格,我希望按钮填满所有空间
答案 0 :(得分:-1)
我遇到了同样的问题。默认按钮带有边距。设置如下按钮属性:
android:layout_marginTop="-3dp"
对左,右和下边距执行相同操作。或者使用以下参数定义新的drawable:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp"
>
<solid android:color="@color/colorButtonGray"/>
<corners
android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
自定义形状没有任何内置边距。