1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

    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">
    <RelativeLayout
        android:id="@+id/RelativeLayout01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <ImageView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/ImageView_MenuHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"></ImageView>
        <TextView
            android:id="@+id/TextView01"
            android:layout_height="wrap_content"
            android:text="@string/admin"
            android:textSize="@dimen/screen_title_size"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="10"
            android:layout_width="wrap_content"
            android:layout_gravity="fill_horizontal|center"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:shadowColor="@android:color/white"
            android:textColor="@color/title_color"></TextView>
        <ImageView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/ImageView_MenuHeader2"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"
            android:layout_gravity="right|center_vertical"
            android:layout_width="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"></ImageView>
    </RelativeLayout>    
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        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="wrap_content">     
            <Spinner
                android:id="@+id/Spinner_Table"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:drawSelectorOnTop="true"></Spinner>
             <TextView
                android:layout_width="wrap_content"
                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
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent">  
             <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"></Button>
    </RelativeLayout>
 </LinearLayout>

All of the above xml is within a liner layout...The problem is when the text view admin table get written data too in the application there is a large amount of data shown...the data shows fine...however when the user scrolls to the bottom of the screen they should see the logout button, but it is not showing?

2 Answers 2

1

Try setting the ScrollView layout_height to something static like 60dp and set the layout_weight to 1.0 which will cause it to expand to its maximum without going off the screen.

<ScrollView
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:layout_weight="1.0"
    android:isScrollContainer="true"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    ...
</ScrollView>

This however should cause the Logout button to show up all the time below the ScrollView.

In order to get the button to appear at the bottom of the ScrollView try moving the RelativeLayout inside the ScrollView and nesting them in another LinearLayout like so:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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">
    <RelativeLayout
        android:id="@+id/RelativeLayout01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        ... your header views ...
    </RelativeLayout>    
    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:scrollbars="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">     
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">     
                ... data you load ...
            </LinearLayout>
            <RelativeLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent">  
                 <Button 
                    android:id="@+id/Logout" 
                    android:text="@string/Logout" 
                    android:layout_width="wrap_content" 
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"></Button>
            </RelativeLayout>
        </LinearLayout>
    </ScrollView>
 </LinearLayout>
Sign up to request clarification or add additional context in comments.

Comments

0

Some comments:

You don't need to define widgets like this:

 <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"></Button>

You can do it like this:

 <Button 
                android:id="@+id/Logout" 
                android:text="@string/Logout" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"/>

From my point of view, the issue you are having is that the ScrollView is taking all the space left.

Try defining the RelativeLayout with the Button first and tell the ScrollView to be android:layout_above the RelativeLayout.

2 Comments

The button appears on the screen but the scrollview and anything inside does not
Is there a way of putting the button inside the scroll view, and then telling the button to always be at the bottom of the scroll view, all i want is the button to stay at the bottom of the screen all the time

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.