How to do a Scroll with multiple layauts?

0

I have problems when doing the scroll.

Create multiple layouts to make a form with images and text boxes. But when it comes to compiling and testing, it does not scroll

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:fillViewport="true"
tools:context="com.altafulla.lostdocument.login">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:padding="1dp"
            android:src="@android:drawable/sym_action_email"
            android:tint="@color/colorPrimaryDark" />

        <EditText
            android:id="@+id/txtemaill"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:hint="Email"
            android:inputType="textEmailAddress"
            android:textSize="25sp" />
</LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="30dp"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:src="@mipmap/pass"
            android:tint="@color/colorPrimaryDark" />

        <EditText
            android:id="@+id/txtpass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@android:color/white"
            android:hint="Contraseña"
            android:inputType="textPassword"
            android:textSize="25sp" />
</LinearLayout>



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="30dp"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            android:src="@mipmap/pass"
            android:tint="@color/colorPrimaryDark" />

        <EditText
            android:id="@+id/txtrpass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@android:color/white"
            android:hint="Repetir Contraseña"
            android:inputType="textPassword"
            android:textSize="25sp" />

         </LinearLayout


         </LinearLayout>
         </ScrollView>
    
asked by Víctor Altafulla 01.09.2017 в 02:20
source

2 answers

0

Place the ScrollView within a RelativeLayout .

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.altafulla.lostdocument.login">

    <ScrollView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorAccent"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

               <ImageView
                   android:layout_width="wrap_content"
                   android:layout_height="match_parent"
                   android:background="@android:color/white"
                   android:padding="1dp"
                   android:src="@android:drawable/sym_action_email"
                   android:tint="@color/colorPrimaryDark" />

               <EditText
                   android:id="@+id/txtemaill"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:background="@android:color/white"
                   android:hint="Email"
                   android:inputType="textEmailAddress"
                   android:textSize="25sp"/>
           </LinearLayout>


           <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="30dp"
                    android:layout_height="match_parent"
                    android:background="@android:color/white"
                    android:src="@mipmap/pass"
                    android:tint="@color/colorPrimaryDark" />

                <EditText
                    android:id="@+id/txtpass"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:background="@android:color/white"
                    android:hint="Contraseña"
                    android:inputType="textPassword"
                    android:textSize="25sp" />
            </LinearLayout>



            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="30dp"
                    android:layout_height="match_parent"
                    android:background="@android:color/white"
                    android:src="@mipmap/pass"
                    android:tint="@color/colorPrimaryDark" />

                <EditText
                    android:id="@+id/txtrpass"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:background="@android:color/white"
                    android:hint="Repetir Contraseña"
                    android:inputType="textPassword"
                    android:textSize="25sp" />
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

</RelativeLayout>
    
answered by 01.09.2017 в 03:08
0

The scrollview of android can only contain one child, inside the main son you can put your other layouts. I leave you an example.

<ScrollView>
  <LinearLayout>  <!-- El unico hijo del ScrollView-->

    <!-- Aca pueden ir todos tus layouts necesarios -->
  </LinearLayou>
</ScrollView>
    
answered by 08.09.2017 в 21:43