Reputation: 1083
I'm trying to get my relative layout to scroll. I added the scroll view as a parent but when I tilt the phone, or emulator to horizontal, it doesn't scroll.
I've tried a few different solutions but none of them seem to work. Some include: No scrolling in scrollview, ScrollView not Working - Relative Layout, and RelativeLayout with scrollview not scrolling
The code is the following:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:layout_width="200dp"
android:id="@+id/register_button"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Register" />
<EditText
android:id="@+id/email2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/register_button"
android:layout_alignLeft="@+id/register_button"
android:layout_alignRight="@+id/register_button"
android:hint="Re-Enter Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/email1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/email2"
android:layout_alignLeft="@+id/email2"
android:layout_alignRight="@+id/email2"
android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/password2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/email1"
android:layout_alignLeft="@+id/email1"
android:layout_alignRight="@+id/email1"
android:hint="Repeat Password"
android:inputType="textPassword" />
<EditText
android:id="@+id/password1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/password2"
android:layout_alignLeft="@+id/password2"
android:layout_alignRight="@+id/password2"
android:hint="Password"
android:inputType="textPassword" />
<EditText
android:id="@+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/password1"
android:layout_alignLeft="@+id/password1"
android:layout_alignRight="@+id/password1"
android:hint="Last Name"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
<EditText
android:id="@+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/lastName"
android:layout_alignLeft="@+id/lastName"
android:layout_alignRight="@+id/lastName"
android:hint="First Name"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
<EditText
android:id="@+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/firstName"
android:layout_alignLeft="@+id/firstName"
android:layout_alignRight="@+id/firstName"
android:hint="Username"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</RelativeLayout>
</ScrollView>
Thanks!
Upvotes: 5
Views: 3805
Reputation: 985
android:fillViewport="true"
add this line as your scroll view attribute :)
Upvotes: 0
Reputation: 36302
Your RelativeLayout
is set to fill_parent
. If it's the same size as its ScrollView
parent, there's nothing to scroll. Make it wrap_content
instead and properly layout its children to imply a height.
Upvotes: 3