2013-07-13 2 views
1

как добавить строку seprater в betwen edittext и кнопку ниже - это мой код, помогите мне, plz, я следую этому руководству How to add (vertical) divider to a horizontal LinearLayout? не помогает мне, я просто хочу добавить строку seprate rin bedtween edittext и кнопкакак добавить seprater между edittext и кнопкой

<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

Проверьте это, я добавил seperator –

0

Если вы используете линейный макет, это дает вам возможность установить разделитель и его интервал.

Если вам это нужно Relative Layout, вы могли бы рассмотреть вопрос о создании View и прикрепив ее на дне редактирования текста с некоторым запасом

Надеется, что это помогает

+0

youre используя относительный, чтобы вы могли поместить свое мнение anuywhere относительно друг друга – Giant

0

Пожалуйста, проверьте андроид: намек =» ПОИСК SCHOOL BY NAME " здесь вы получите ошибку, потому что вы не можете использовать **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" 

Edit:

, если вы все еще не в состоянии сделать 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> 
Смежные вопросы