2015-07-30 2 views
0

Я пытаюсь разместить мои элементы таким образом, чтобы кнопка занимала нижнюю часть экрана, а остальные элементы располагались последовательно в верхней части экрана, но без успеха. Последний EditExt (opedt) всегда отображается немного удаленно от остальных где-то посередине экрана. Какие изменения имеют их в желаемом порядке? Вот мой файл разметки XML:Элементы заказа в файле макета

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:background="@drawable/beezlinkbackg" 
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context="gsie.beezlink.OpportunityActivity"> 

    <RelativeLayout 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:gravity="center" > 
     <Button 
      android:layout_width= "match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/posterbtn" 
      android:background="#008000" 
      android:id="@+id/posterbtn" 
      /> 

    </RelativeLayout> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/cinteretxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/cinteretxt" 
     android:layout_alignParentTop="true" 
     /> 

    <Spinner 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/cinteretspin" 
     android:layout_below="@+id/cinteretxt" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/optitretxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/optitretxt" 
     android:layout_below="@+id/cinteretspin" 
     /> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/optitreedt" 
     android:layout_below="@+id/optitretxt" 
     android:hint="@string/hintoptitre" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/optxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/optxt" 
     android:layout_below="@+id/optitreedt" 
     /> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/opedt" 
     android:hint="@string/hintpost" 
     android:layout_below="@+id/optxt" 
     android:layout_above="@+id/footer" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

Edit: Похоже, я присудили очки без хорошего тестирования. Когда я набираю длинный текст в последнем EditText (opedt), он перекрывает кнопку внизу. Текст находится поверх кнопки. Я хочу, чтобы текст остановился только до нажатия кнопки и свитков.

+1

Второй относительный макет – Raghunandan

+0

как ненужный идти об этом? –

+0

удалите вторую относительную компоновку и добавьте 'android: layout_alignParentBottom =" true "' к кнопке – finki

ответ

0

Удалите RelativeLayout-обертку от вашей кнопки и добавить следующий атрибут вашей кнопки: android:layout_alignParentBottom="true"

0

вы можете использовать следующий код для получения идеального вашей кнопки всегда в нижней части окна и других элементов будет находиться на вершине в упорядоченном формат.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context="gsie.beezlink.OpportunityActivity"> 

    <Button 
     android:layout_width= "match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/posterbtn" 
     android:background="#008000" 
     android:id="@+id/posterbtn" 
     android:gravity="center" 
     android:layout_alignParentBottom="true" 
     /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/cinteretxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/cinteretxt" 
     android:layout_alignParentTop="true" 
     /> 

    <Spinner 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/cinteretspin" 
     android:layout_below="@+id/cinteretxt" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/optitretxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/optitretxt" 
     android:layout_below="@+id/cinteretspin" 
     /> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/optitreedt" 
     android:layout_below="@+id/optitretxt" 
     android:hint="@string/hintoptitre" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/optxt" 
     android:textSize="20sp" 
     android:textStyle="bold" 
     android:id="@+id/optxt" 
     android:layout_below="@+id/optitreedt" 
     /> 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/opedt" 
     android:hint="@string/hintpost" 
     android:layout_below="@+id/optxt" /> 

</RelativeLayout> 

Cheers ..!

0

если содержание выходит из поля зрения вы можете использовать вид прокрутки

<RelativeLayout 
    android:layout_above:"@+id/posterbtn" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/cinteretxt" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:id="@+id/cinteretxt" 
    android:layout_alignParentTop="true" 
    /> 

<Spinner 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/cinteretspin" 
    android:layout_below="@+id/cinteretxt" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/optitretxt" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:id="@+id/optitretxt" 
    android:layout_below="@+id/cinteretspin" 
    /> 
<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/optitreedt" 
    android:layout_below="@+id/optitretxt" 
    android:hint="@string/hintoptitre" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/optxt" 
    android:textSize="20sp" 
    android:textStyle="bold" 
    android:id="@+id/optxt" 
    android:layout_below="@+id/optitreedt" 
    /> 
<EditText 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/opedt" 
    android:hint="@string/hintpost" 
    android:layout_below="@+id/optxt" 
    android:layout_above="@+id/footer" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

</RelativeLayout> 
    <Button 
     android:layout_alignParentBottom="true" 
     android:layout_width= "match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/posterbtn" 
     android:background="#008000" 
     android:id="@+id/posterbtn" 
     /> 

Смежные вопросы