2

xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bkgrnd">
<ScrollView
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="true"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">     
        <Spinner
            android:id="@+id/Spinner_Table"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:drawSelectorOnTop="true"></Spinner>
         <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textSize="@dimen/help_text_size"
            android:textStyle="bold"
            android:gravity="center"
            android:id="@+id/Blank"></TextView>
        <TextView  
            android:id="@+id/admintable" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"></TextView>
        <Button 
            android:id="@+id/Logout" 
            android:text="@string/Logout" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"></Button>
        </LinearLayout>
</ScrollView>

All I want to do is the last button on this activity to be displayed at the bottom of the view. If I move the button outside the scroll view I get an error. What should I do?

2 Answers 2

3

Try using a RelativeLayout, a little hard at the begining but very powerful.

Also I think this is what you try to accomplish

I can't test it right now, but the RelativeLayout alternative should look like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bkgrnd">
    <Button 
        android:id="@+id/Logout" 
        android:text="@string/Logout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"></Button>
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_above="@id/Logout"
        android:isScrollContainer="true"
        android:scrollbars="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true">
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">     
            <Spinner
                android:id="@+id/Spinner_Table"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:drawSelectorOnTop="true"></Spinner>
             <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="@dimen/help_text_size"
                android:textStyle="bold"
                android:gravity="center"
                android:id="@+id/Blank"></TextView>
            <TextView  
                android:id="@+id/admintable" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"></TextView>
        </LinearLayout>
    </ScrollView>
</RelativeLayout>
Sign up to request clarification or add additional context in comments.

4 Comments

Nope messes the screen up and the titles i have all overlaps etc
and the button goes missing sometimes i am playing with relative layout...is there an alternative
I added a link to another solution that maybe can help you out. As I said I can't test right now my relative layout solution, but I'm using similar things in my projects and correctly setup it works just nice
I think I found a problem, is it necessary that the TextView with Blank id has a height of "fill_parent"? I updated my relative layout solution changing it to wrap_content
1

Well Usman what you should do is implement your layout hierarchy as below

LinearLayout
          |->your ScrollView
          |                  |->Your Linearlayout & then spinner in it etc.etc.(& remove button from this layout)
          |->a new LinearLayout(to hold your button)
                             |->your Logout Button here

and you are done!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.