Friday, 26 December 2014

ScrollView keeps overlapping items below it



I have a ScrollView, and below it two horizontally aligned buttons. I want the buttons to be A) at the bottom of the window when the scrollview doesn't fill the entire window, and B) to stay below the scrollview when it IS larger than the window.


Currently, the buttons are successfully placed at the bottom of the screen when the scrollview isn't filling the whole window, but when the scrollview has too much data to fit in the window (e.g. when the phone is turned to landscape view) the scrollview data overlaps over the buttons.


I'm having some difficulty figuring out how to meet both of these conditions simultaneously just by using XML. Perhaps I've no choice but to introduce some programmatic checking? Anyway, here's my code:



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">

<TextView android:id="@+id/groupHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#000000"
android:textSize="25sp"
android:text="@string/groupHeader" />


<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/groupHeader" >

<LinearLayout
android:layout_gravity="right"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/groupCreate" >
</LinearLayout>
</ScrollView>

<Button
android:id="@+id/groupcreate_button_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:text="@string/groupcreate_button_new" />

<Button
android:id="@+id/groupcreate_button_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:text="@string/groupcreate_button_next" />

</RelativeLayout>


Thanks for any and all assistance in advance.


No comments:

Post a Comment