Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Scroll View to the android layout

I have a relative layout in which i want to add a scrollView, the problem is when ever i add the scroll view, all of my relatively set widgets lost their places, i have tried each and every possibility but i am unable to set the scroll view properly, can anybody help me in that? I want to put the scroll view to all of my elements of the xml file.

NEW CODE:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff" >

    <ImageButton
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="140dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_weight="0.9"
        android:background="@drawable/subscribe_second_top"
        android:orientation="vertical" >
    </ImageButton>





            <EditText
                android:id="@+id/editText1"
                android:layout_width="270dp"
                android:layout_height="wrap_content"
                android:layout_below="@+id/bebasNeueTextView1"
                android:layout_centerHorizontal="true"
                android:ems="10"
                android:inputType="textEmailAddress" />

            <TextView
                android:id="@+id/bebasNeueTextView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editText1"
                android:layout_centerHorizontal="true"
                android:text="THE EMAIL YOU WILL USE TO GET ALL YOUR APPS CREATED BY THE SOFT"
                android:textColor="#000000"
                android:textSize="7sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/bebasNeueTextView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/editText2"
                android:layout_centerHorizontal="true"
                android:text="YOUR GOOGLE PLAY STORE ORDER NUMBER, IN ORDER TO PROVE YOU BOUG"
                android:textColor="#000000"
                android:textSize="7sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/bebasNeueTextView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/bebasNeueTextView2"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="16dp"
                android:text="ENTER YOUR PLAY STORE ORDER NUMBER"
                android:textColor="#94c23e"
                android:textSize="13sp"
                android:textStyle="bold" />

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="80dp"
                android:layout_alignParentBottom="true"
                android:background="@drawable/subscribe_second_bottom"
                android:paddingBottom="5dp"
                android:paddingTop="30dp" >

                <com.apkcreator.fwd.BebasNeueButton
                    android:id="@+id/finishButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_centerHorizontal="true"
                    android:background="#94c23e"
                    android:paddingBottom="10dp"
                    android:paddingLeft="30dp"
                    android:paddingRight="30dp"
                    android:paddingTop="10dp"
                    android:text="FINISH"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </RelativeLayout>

            <TextView
                android:id="@+id/bebasNeueTextView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="170dp"
                android:text="ENTER YOUR EMAIL"
                android:textColor="#94c23e"
                android:textSize="13sp"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/editText2"
                android:layout_width="270dp"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/editText1"
                android:layout_below="@+id/bebasNeueTextView4"
                android:ems="10" 
                android:layout_centerHorizontal="true">


            </EditText>

</RelativeLayout>
 </ScrollView>
like image 851
Hassaan Rabbani Avatar asked Oct 16 '13 07:10

Hassaan Rabbani


People also ask

How do I add a view to scroll view?

To add multiple views within the scroll view, make the direct child you add a view group, for example LinearLayout , and place additional views within that LinearLayout. Scroll view supports vertical scrolling only. For horizontal scrolling, use HorizontalScrollView instead.


1 Answers

Check this link: How to add scroll bar to the Relative Layout?

Your problem may be related with the viewport, android:fillViewport="true" on the ScrollLayout should solve your problem.

Viewing your xml, You can set this file using a vertical LinearLayout, much more simple for this use case.

BTW, my advise is to avoid scrollbars on user inputs like registration, login... Your form only contains 2 fields, I'm sure you can arrange it to be all shown on screen at once (much better UX!).

like image 152
Alex Cabrera Avatar answered Oct 06 '22 06:10

Alex Cabrera