Проблема относительного расположения Android - PullRequest
2 голосов
/ 23 апреля 2010

Я просто не могу отобразить кнопку внизу экрана.У меня есть 2 textview и 2 edittexts, установленные как пропавшие, и они становятся видимыми, когда пользователь нажимает флажок.Только тогда моя кнопка будет расположена правильно. В противном случае она будет расположена поверх приложения при запуске моего приложения (см. Здесь: http://www.shrani.si/f/3V/10G/4nnH4DtV/layoutproblem.png) Я также пробовал android: layout_alignParentBottom = "true", но это тоже не помогает.

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">


 <TextView android:id="@+id/txt1" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="Krajevna skupnost: "
    android:layout_alignParentTop="true" />

 <Spinner 
    android:id="@+id/spinner1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:prompt="@string/ks_prompt"
    android:layout_below="@id/txt1"    
/>

 <TextView android:id="@+id/txt2" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="Zadeva: "
    android:layout_below="@id/spinner1" />

 <Spinner 
    android:id="@+id/spinner2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:prompt="@string/pod_prompt"
    android:layout_below="@id/txt2"
/>
<TextView android:id="@+id/tv1" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="Zadeva: "
    android:layout_below="@id/spinner2" />

<EditText android:id="@+id/prvi" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/tv1" />
<TextView android:id="@+id/tv2" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/prvi"
    android:text="Vsebina: " />
<EditText android:id="@+id/drugi" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/tv2" />

    <CheckBox android:id="@+id/cek" android:text="Obveščaj o odgovoru"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_below="@id/drugi" />

<TextView android:id="@+id/tv3" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/cek"
    android:text="Email: " 
    android:visibility="gone"/> 
<EditText android:id="@+id/tretji" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/tv3"
    android:visibility="gone" />

    <TextView android:id="@+id/tv4" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@id/tretji"
    android:visibility="gone"
    android:text="Telefon: " /> 

<EditText android:id="@+id/cetrti" android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:visibility="gone"
    android:layout_below="@id/tv4" />


    <Button android:id="@+id/gumb"
    android:text="Klikni"
    android:typeface="serif" android:textStyle="bold"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center" 
    android:layout_below="@id/cetrti" />

           </RelativeLayout>

          </ScrollView>

Ответы [ 2 ]

1 голос
/ 23 апреля 2010

Удалите ScrollView и установите для android: layout_alignParentBottom = "true" нижнюю кнопку. Также удалите эту строку: android: layout_below = "@ id / cetrti". Если вам действительно нужен ScrollView, вы можете сделать его примерно таким:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ScrollView
       ...
       <RelativeLayout
          ...
       </RelativeLayout>
    </ScrollView>
   <Button
      android:layout_alignParentBottom="true"
      ...
</RelativeLayout>
0 голосов
/ 23 апреля 2010

Я запустил его на устройстве 2.1 - и все выглядело нормально, как есть. Кнопка расположена ниже флажка. Так что я не уверен, в чем проблема. Как быстрое решение, которое сработает наверняка - измените относительное расположение на LinearLayout. Это немного дороже, но для вашей цели IMO должно работать

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...