tags:

views:

1046

answers:

2

Hello!

I just can't display the button at the bottom of the screen. I have 2 textviews and 2 edittexts set as gone, and they become visible when user clicks checkbox. It's only then that my button gets positioned properly Otherwise it sits on top of the app at launch of my app.(see here: http://www.shrani.si/f/3V/10G/4nnH4DtV/layoutproblem.png) I also tried android:layout_alignParentBottom="true" but that doesnt 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>
+1  A: 

Remove ScrollView and set android:layout_alignParentBottom="true" to your bottom button. Also remove this line: android:layout_below="@id/cetrti". If you really need the ScrollView, you could make it 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>
janfsd
A: 

I ran it o 2.1 device - and it looked ok as it is . Button is positioned below checkbox. So i'm not sure what the problem is. As a quick fix that gonna work for sure - change relative layout to the LinearLayout. It little bit more expensive, but for your purpose IMO should work

Alex Volovoy
I think he wants to get the button at the bottom of the screen.
janfsd
question is does he want to have this button be scrolled with the content or not. By his layout design, he intended whole layout to be scrolled including the button.
Alex Volovoy
I tried my code on 1.6 emulator and it worked fine. Problem is on 1.5. Then i changed my layout to Linear(inside scrollview) and now everything is good. Thank you guys for your swift response.
DixieFlatline