2013-07-13 90 views
1

如何在edittext和button下方添加行seprater是我的代码帮助我PLZ我按照此教程How to add (vertical) divider to a horizontal LinearLayout?不帮助我pl我只想添加行seprate rin bedtween edittext和按钮如何在edittext和按钮之间添加seprater

<RelativeLayout 

android:layout_height="wrap_content" 
android:background="#a8a8a8" 
android:layout_width="fill_parent"> 
<EditText 
    android:id="@+id/EditText01" 
    android:hint="Enter some text..." 
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent" 
    android:background="#a8a8a8" 
    android:paddingTop="15dp" 
    android:hint="SEARCH SCHOOL BY NAME" 
    android:layout_toLeftOf="@+id/Button01" 
    android:layout_height="wrap_content"> 

</EditText> 



<Button 
    android:id="@+id/Button01" 
    android:text="Press Here!" 
    android:layout_width="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_height="wrap_content"></Button> 
</RelativeLayout> 
+0

看到我更新的答案! –

回答

0

您正在使用相对布局,因此您可以调整布局视图中的间距。

1

你可以把编辑文本和下面的按钮之间<View/> ..

<View 
    android:layout_width="wrap_content" 
    android:layout_height="0dip" 
    android:layout_marginLeft="10dip" 
    android:layout_marginRight="10dip" 
    android:background="@color/Gray" /> 
0

如果使用线性布局中使用的LinearLayout代替RelativeLayout

<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000000" 
android:orientation="vertical" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#a8a8a8" > 

    <ImageView 
     android:id="@+id/test_button_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/icon" > 
    </ImageView> 

    <TextView 
     android:id="@+id/test_button_text2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/test_button_image" 
     android:layout_toRightOf="@+id/test_button_image" 
     android:text="San Diego Unified" 
     android:textColor="#ffffff" 
     android:textSize="20sp" > 
    </TextView> 

    <TextView 
     android:id="@+id/test_button_text1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/test_button_text2" 
     android:layout_below="@+id/test_button_text2" 
     android:text="SCHOOL DISTRICT" 
     android:textColor="#ffffff" > 
    </TextView> 
</RelativeLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#ffffff" 
    android:orientation="horizontal" > 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left|center_vertical" 
     android:layout_weight="1" 
     android:ellipsize="end" 
     android:gravity="left|center_vertical" 
     android:singleLine="true" 
     android:text="HEALTHY BODIES HEALTHY MINDS " 
     android:textSize="12sp" /> 

    <ImageButton 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/facebook" /> 

    <ImageButton 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/twitter" 
     android:text="Button Text" /> 
</LinearLayout> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#a8a8a8" > 

    <EditText 
     android:id="@+id/EditText01" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="@+id/seperator" 
     android:background="#a8a8a8" 
     android:hint="SEARCH SCHOOL BY NAME" 
     android:paddingTop="15dp" > 
    </EditText> 

    <View 
     android:id="@+id/seperator" 
     android:layout_width="1dp" 
     android:layout_height="fill_parent" 
     android:layout_alignBottom="@+id/Button01" 
     android:layout_toLeftOf="@+id/Button01" 
     android:background="@android:color/white" /> 

    <Button 
     android:id="@+id/Button01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:text="Press Here!" > 
    </Button> 
</RelativeLayout> 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#a8a8a8" > 

    <ImageView 
     android:id="@+id/test_button_image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/icon" > 
    </ImageView> 

    <TextView 
     android:id="@+id/test_button_text2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/test_button_image" 
     android:layout_toRightOf="@+id/test_button_image" 
     android:m="" 
     android:text="San Diego Unified" 
     android:textColor="#ffffff" 
     android:textSize="20sp" > 
    </TextView> 
</RelativeLayout> 
+0

不帮我 – user2567933

+0

这是我的完整代码帮助我如何将分隔符放在edittext和按钮之间 – user2567933

+0

检查出来,我添加了分隔符 –

0

,它给你的选项设置分频器及其间距。

如果你需要在相对布局,则可以考虑创建一个视图,并与一些余量附着在编辑文本的底部

希望这有助于

+0

youre使用亲戚,所以你可以把你的看法anuywhere相对于彼此 – Giant

0

请检查机器人:提示=”按名称搜索学校“在这里你会得到错误,因为你不能使用**android:hint=""**这个或任何其他属性两次!

检查你的代码如下:

<EditText 
    android:id="@+id/EditText01" 
    android:hint="Enter some text..." 
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent" 
    android:background="#a8a8a8" 
    android:paddingTop="15dp" 
    android:hint="SEARCH SCHOOL BY NAME" 
    android:layout_toLeftOf="@+id/Button01" 
    android:layout_height="wrap_content"> 

所以将其更改为:

要么使用android:hint="Enter some text..."

android:hint="SEARCH SCHOOL BY NAME" 

编辑:

,如果你仍然无法得出seprater

尝试

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#a8a8a8" > 

    <EditText 
     android:id="@+id/EditText01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="@+id/my_view" 
     android:background="#a8a8a8" 
     android:hint="Enter some text..." 
     android:paddingTop="15dp" > 
    </EditText> 

    <View 
     android:id="@+id/my_view" 
     android:layout_width="5dp" 
     android:layout_height="match_parent" 
     android:layout_alignBottom="@+id/EditText01" 
     android:layout_marginLeft="5dip" 
     android:layout_marginRight="5dip" 
     android:layout_toLeftOf="@+id/Button01" 
     android:background="#fff" /> 

    <Button 
     android:id="@+id/Button01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:text="Press Here!" > 
    </Button> 
</RelativeLayout> 
相关问题