水平线填充

时间:2011-04-18 16:13:20

标签: android

我正在尝试在两个EditText小部件之间添加一条水平线,但奇怪的是该行底部没有填充,因此它看起来“粘在”它下面的小部件。

这是我的代码(在layout.xml中,在具有垂直方向的LinearLayout内):

    <EditText android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:capitalize="sentences"
        android:singleLine="true"
        android:maxLength="30" />
    <View android:background="#FF00FF00" 
        android:layout_width="fill_parent"
        android:layout_height="1dip" />
    <EditText android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:scrollbars="vertical"
        android:capitalize="none"
        android:autoLink="all"
        android:maxLines="8" />

这就是它的样子:

enter image description here

我想在线下添加一些填充。我在View小部件中尝试使用android:paddingBottom,并在下面的EditText小部件中使用android:paddingTop,但结果是相同的(它被忽略)。

2 个答案:

答案 0 :(得分:5)

使用边距而不是使用填充。 在xml中使用以下属性:

android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"

希望这能解决你的问题......:)

答案 1 :(得分:3)

使用保证金。填充是视图内容周围的区域。例如,如果您为EditText提供填充,则会增加框的大小(文本周围的区域),但不要在其周围留出任何空间。

相关问题