【问题标题】:how to get rid of default white "space" around an element?如何摆脱元素周围的默认白色“空间”?
【发布时间】:2014-08-15 09:14:45
【问题描述】:

这是我的代码

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
   >
   <TextView android:id="@+id/label"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:text="email"
      />
   <EditText
       android:id="@+id/inputEmail"
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"
       android:layout_below="@id/label"

       />
   <Button 
       android:id="@+id/btnLogin"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@id/inputEmail"
       android:layout_alignParentLeft="true"
       android:padding="0dp"
       />

</RelativeLayout>

输出:http://imgur.com/Ga322Q6

我研究了 padding 的定义是“边框内,边框和实际视图内容之间的空间”并且是“视图内部”(Difference between a View's Padding and Margin) 我最初认为白色空间是填充(在蓝色边框内)并使用它。然而,无论填充如何,空白区域仍然存在。有谁知道如何摆脱这个空白或它叫什么?

【问题讨论】:

    标签: java android padding


    【解决方案1】:

    这是default button padding,您看到您对此无能为力,但您仍然可以在按钮上放置可绘制的背景,这样填充就会消失。

    解决方案:

    为按钮添加背景,使其内部没有填充。

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      相关资源
      最近更新 更多