This is the XML code I have before I attempt to adjust it to be scrollable:
Make sure you leave the version/encoding
line at the very top of your file.
Change RelativeLayout
to ScrollView
and then nest a RelativeLayout
section (containing all of your widgets) inside that new ScrollView
.
Make sure you give the RelativeLayout
some dimensions, which should be the same as the ScrollView
width and height dimensions.
The reason for this nesting of the RelativeLayout
that contains all the widgets is that a ScrollView
element can only have one child element (in this case, the RelativeLayout
, which then has its own children).
Therefore this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- all your widgets -->
</RelativeLayout>
Turns into this code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- all your widgets -->
</RelativeLayout>
</ScrollView>