1

how do i add line seprater in betwen edittext and button below is my code help me plz i follow this tutorial How to add (vertical) divider to a horizontal LinearLayout? is not help me pl i just want to add line seprate rin bedtween edittext and button

 <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>  
Community
  • 1
  • 1
user2567933
  • 31
  • 1
  • 6

5 Answers5

1

You can put <View/> between Edit text and Button as below..

<View
    android:layout_width="wrap_content"
    android:layout_height="0dip"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip"
    android:background="@color/Gray" />
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
Mit Bhatt
  • 1,605
  • 2
  • 13
  • 24
0

You're using a relative layout so you can adjust the spacing however you want to in the layout view.

Razgriz
  • 7,179
  • 17
  • 78
  • 150
0

Use a LinearLayout instead of the 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>
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50
0

If you use a Linear Layout, it gives you the option to set a divider and its spacing.

If you need it in Relative Layout, you might consider creating a View and attaching it onto the bottom of the edit text with some margin

Hope this helps

SalicBlu3
  • 1,874
  • 2
  • 19
  • 32
0

Please check android:hint="SEARCH SCHOOL BY NAME" here you will be getting error, because you can't use **android:hint=""** this or any other property twice !

Check your below Code :

<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">

So change it to :

either use android:hint="Enter some text..."

or

android:hint="SEARCH SCHOOL BY NAME"

Edit:

if you are still not able to draw seprater

Try :

   <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>
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71