1

I have designed a signup screen in which I have a Scroll view , But Scroll view is not working.

I am not able to find why Scroll is not working , Help me with this.

Below is the code for reference:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include
        android:id="@+id/tool_bar"
        layout="@layout/tool_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <ImageView
            android:id="@+id/sign_up_profile_image"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="30dp"
            android:background="@drawable/shape_rectangle_rounded_corner"
            android:padding="10dp"
            android:scaleType="fitXY"
            android:src="@drawable/icon_avatar" />


        <RelativeLayout
            android:id="@+id/container_two"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/container_three"
            android:layout_below="@+id/sign_up_profile_image"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="20dp"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/first_last_name_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:weightSum="100">

                <ui.customviews.MaterialEditText
                    android:id="@+id/sign_up_first_name_edit_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="1dp"
                    android:layout_marginTop="2dp"
                    android:layout_weight="50"
                    android:hint="@string/first_name_hint"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName"
                    android:textSize="18sp"
                    app:baseColor="#363636"
                    app:floatingLabel="normal"
                    app:primaryColor="#000000" />

                <customviews.MaterialEditText
                    android:id="@+id/sign_up_last_name_edit_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="1dp"
                    android:layout_marginTop="2dp"
                    android:layout_weight="50"
                    android:hint="@string/last_name_hint"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName"
                    android:textSize="18sp"
                    app:baseColor="#363636"
                    app:floatingLabel="normal"
                    app:primaryColor="#000000" />
            </LinearLayout>

            <ui.customviews.MaterialEditText
                android:id="@+id/sign_up_email_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/first_last_name_container"
                android:hint="@string/email"
                android:imeOptions="actionNext"
                android:inputType="textEmailAddress"
                android:textSize="18sp"
                app:baseColor="#363636"
                app:floatingLabel="normal"
                app:primaryColor="#000000"

                />

            <ui.customviews.MaterialEditText
                android:id="@+id/sign_up_password_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/sign_up_email_edit_text"
                android:hint="@string/password"
                android:imeOptions="actionDone"
                android:inputType="textPassword"
                android:textSize="18sp"
                app:baseColor="#363636"
                app:floatingLabel="normal"
                app:primaryColor="#000000" />

        </RelativeLayout>


        <RelativeLayout
            android:id="@+id/container_three"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="@dimen/activity_vertical_margin">


            <TextView
                android:id="@+id/sign_up_terms_text_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:gravity="center_horizontal"
                android:lineSpacingExtra="2dp"
                android:lineSpacingMultiplier="1.2"
                android:text="By signing up, you accept to the Terms and Conditions and Privacy Policy"
                android:textColor="#6b6b6b"
                android:textSize="14sp" />

            <Button
                android:id="@+id/sign_up_accept_button"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_below="@+id/sign_up_terms_text_view"
                android:layout_marginLeft="@dimen/activity_vertical_margin"
                android:layout_marginRight="@dimen/activity_vertical_margin"
                android:background="#025961"
                android:text="@string/accept_and_signup"
                android:textColor="@android:color/white"
                android:textSize="14sp" />
        </RelativeLayout>
    </RelativeLayout>
</ScrollView>

</LinearLayout>
Pankaj
  • 7,908
  • 6
  • 42
  • 65
Naga
  • 1,931
  • 4
  • 25
  • 42

2 Answers2

0

solution can be change ScrollView to:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    >

Then you should change nested's layout height as well

Stefano Vuerich
  • 996
  • 1
  • 7
  • 28
  • Let me try, Yes you just have changed height – Naga Jul 17 '15 at 07:00
  • Then I think you'll have to change nested layouts heights as well – Stefano Vuerich Jul 17 '15 at 07:02
  • Yeah I am guising the same , thinking to redesign it but before that I wanted to check if I am making any blunder – Naga Jul 17 '15 at 07:04
  • no it is not working , all the layout is getting collapsed – Naga Jul 17 '15 at 07:07
  • Try to assign to the ScrollView's nested layout a fixed height...just to try...then you'll have to re-deign it – Stefano Vuerich Jul 17 '15 at 07:08
  • yes you are right , one more problem is when Soft key board is up for typing then also it not scrolling – Naga Jul 17 '15 at 07:14
  • Yes, but this is the custom implementation – Stefano Vuerich Jul 17 '15 at 07:17
  • So any idea how to scroll he whole view when soft key board is pop up , I have tried with adjustPan, and other options too but did not work – Naga Jul 17 '15 at 07:19
  • take a look here http://stackoverflow.com/questions/9989130/page-scroll-when-soft-keyboard-poped-up – Stefano Vuerich Jul 17 '15 at 07:20
  • So if others methods doesn't work...but that's quite strange, don't you think? you can set an OnTouchListener on the ScrollView and listen for swipes on the Y axis. Then when the user start swiping call ScrollView's scrollTo method, passing int x and y you want to reach http://developer.android.com/reference/android/widget/ScrollView.html#scrollTo(int, int) – Stefano Vuerich Jul 17 '15 at 07:28
  • Yes its very strange , the way you are suggesting is looks pretty good – Naga Jul 17 '15 at 07:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/83510/discussion-between-stefano-vuerich-and-nagendra). – Stefano Vuerich Jul 17 '15 at 07:34
0

Try Like this, Add inside Linear layout , it will Scroll till End of the Page.

<RelativeLayout 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">

     <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

// Your xml Code Put Here

        </LinearLayout>
    </ScrollView>
</Relativelayout>
Android Dev
  • 421
  • 8
  • 26