2011-04-18 157 views
2

我试图在两个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,但结果是一样的(它被忽略)。

回答

5

而不是使用填充使用保证金。 使用以下属性的XML:

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

希望这将解决您的问题... :)

+0

打秒我:) – Maximus 2011-04-18 16:20:42

3

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

+0

你是对的。我用android:marginBottom测试过,因为它与android:paddingBottom有关,但它不存在。在保证金中,它需要名称中的“布局”部分,即android:layout_marginBottom ...这非常令人困惑...... – 2011-04-18 16:31:02

+0

需要适应。原因“layout_”是名称的一部分,因为边距是视图的“布局参数”的一部分,而不是视图的单个属性。 – Maximus 2011-04-18 16:37:25

+0

感谢您的澄清:) – 2011-04-18 16:43:29