Android 有没有办法完全消除包含按钮的线性布局中的填充?

Android 有没有办法完全消除包含按钮的线性布局中的填充?,android,android-layout,android-linearlayout,padding,Android,Android Layout,Android Linearlayout,Padding,我尝试了以下方法,试图在水平线性布局中显示两个按钮,按钮的边缘与线性布局的边框齐平。令我惊讶的是,我发现在按钮和线性布局的左、右和下边缘之间仍然存在填充。只有按钮的上边缘最终与线性布局的边框齐平。为什么呢?有没有办法控制这种行为?多谢 <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" and

我尝试了以下方法,试图在水平线性布局中显示两个按钮,按钮的边缘与线性布局的边框齐平。令我惊讶的是,我发现在按钮和线性布局的左、右和下边缘之间仍然存在填充。只有按钮的上边缘最终与线性布局的边框齐平。为什么呢?有没有办法控制这种行为?多谢

<LinearLayout android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="#777"
  android:padding="0dip"
  android:layout_margin="0dip">
  <Button android:id="@+id/feeling_done_button"
     android:text="@string/done_button_label"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
     android:layout_weight="1"
     android:padding="0dip"
     android:layout_margin="0dip"/>
  <Button android:id="@+id/feeling_cancel_button"
     android:text="@string/cancel_button_label"
     android:layout_height="wrap_content"
     android:layout_width="match_parent"
     android:layout_weight="1"
     android:padding="0dip"
     android:layout_margin="0dip"/></LinearLayout>

如果你想让它们被一个像素一个像素地推到边缘,你需要使用你自己的9块补丁作为按钮背景,因为Android中的默认9块补丁在其9块补丁背景的边框周围有一些额外的像素。有关此示例,请查看SDK文件夹中的以下文件:

platforms/android-8/data/res/drawable hdpi/btn\u default\u transparent\u normal.9.png

例如,这是我使用默认值得到的结果:

使用我之前制作的定制9-patch:


如果你想让它们被一个像素一个像素地推到边缘,你需要使用你自己的9-patch作为按钮背景,因为Android中的默认9-patch在其9-patch背景的边框周围有一些额外的像素。有关此示例,请查看SDK文件夹中的以下文件:

platforms/android-8/data/res/drawable hdpi/btn\u default\u transparent\u normal.9.png

例如,这是我使用默认值得到的结果:

使用我之前制作的定制9-patch:


Hi,出于某种原因,使用9-patch作为按钮仍然会使用大量填充,而使用textView则不会。怎么可能呢?嗨,不知什么原因,使用9-补丁作为按钮仍然会使用大量的填充,而使用textView则不会。怎么可能呢?