I've been struggling with this for a while and been unable to find an answer so far. I have a TableLayout inside a RelativeLayout. I need the TableLayout to be scrollable, not the relative layout as it has static buttons I don't plan on them moving.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_weight="1">
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Encuestas" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="14dp"
android:layout_marginTop="14dp"
android:onClick="SyncServer"
android:text="Sync" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:id="@+id/TableLayout1"
android:layout_alignParentRight="true"
android:layout_below="@+id/button1" >
</TableLayout>
</RelativeLayout>
</ScrollView>
With this code I can scroll the entire screen, but if I try to put the ScrollView on the TableLayout, I'm unable to click on the button I created.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Encuestas" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="14dp"
android:layout_marginTop="14dp"
android:onClick="SyncServer"
android:text="Sync" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_weight="1">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:id="@+id/TableLayout1"
android:layout_alignParentRight="true"
android:layout_below="@+id/button1" >
</TableLayout>
</ScrollView>
</RelativeLayout>
This one doesn't allow me to click on the button. Any suggestions?
Never put a scrollable view inside another scrollable view (that scrolls the same direction). The only exception to this rule is when the Lord appears before you in all his glory and hands you stone tablets engraved with something that says otherwise.
Anyway, the second layout will work with one small modification, you must tell the layout to put the scrollview beneath the button like so:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:layout_below="@id/button1"
android:layout_weight="1">