Android relative placement problem

I just cannot display the button at the bottom of the screen. I have 2 textviews and 2 edittexts that are gone and they become visible when the user clicks a checkbox. It is only then that my button is positioned correctly. Otherwise it sits on top of the app when my app starts up (see here: http://www.shrani.si/f/3V/10G/4nnH4DtV/layoutproblem.png ) I also tried android: layout_alignParentBottom = "true" but that doesn't help either.

 <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


a source to share


2 answers


I launched his 2.1 device - and it looked fine as it is. The button is installed below. So I'm not sure what the problem is. As a quick fix that will definitely work, change the relative layout to LinearLayout. It's a bit more expensive but for your purpose IMO should work



0


a source


Remove ScrollView and set Android: layout_alignParentBottom = "true" to the bottom button. Also remove this line: android: layout_below = "@ id / cetrti". If you really want a ScrollView, you can do something like this:



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

      

+1


a source







All Articles