1

Well, after a day trying to find the ebst solution I couldn't and need your help.

I'm trying to make my app's login screen more interesting and beautiful so I used Scrolling Activity on it.

What I need is to click on the fab button in 2 layouts and jump between them, like in the screenshots (I've cut the upside part which has my company logo). I'm not using intent because of the animation they provide.:

Login. Cick on FAB and go to Settings

Settings. Click FAB and go back to login

First of all, Fragments seems the solution but I never used them and the tutorials I found didn't helped me. I only got the two layouts one above the other.

I tried the answer of J0n0 here and didn't worked either:jono answer is the choosen one

XML of the screens:

Login:

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:id="@+id/nested1"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.ssm.ssmsette.ssm_sette.Version2.ScrollingActivity"
    tools:showIn="@layout/activity_scrolling">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="90dp"
        android:orientation="vertical">

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

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/user" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtUser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="User"
                    android:textColor="@color/green_sette_dark" />

                <EditText
                    android:id="@+id/edtUsername"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:ems="10"
                    android:inputType="textPersonName" />
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="20dp"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:srcCompat="@drawable/password" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtSenha"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Pass"
                    android:textColor="@color/green_sette_dark" />

                <EditText
                    android:id="@+id/edtPassword"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:ems="10"
                    android:inputType="textPassword" />
            </LinearLayout>
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginEnd="22dp"
            android:layout_marginTop="10dp">

            <CheckBox
                android:id="@+id/checkSaveCredentials"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Save" />

            <Button
                android:id="@+id/btnLogin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_gravity="end"
                android:layout_weight="0"
                android:background="@android:color/transparent"
                android:onClick="login"
                android:text="Login"
                android:textAlignment="textEnd"
                android:visibility="visible" />

            <ProgressBar
                android:id="@+id/progressBar1"
                style="?android:attr/progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/btnLogin"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_alignRight="@+id/checkSaveCredentials"
                android:layout_weight="0"
                android:visibility="visible" />
        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="20dp"
            android:orientation="horizontal">

        </LinearLayout>

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

Settings:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:id="@+id/nested2"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.ssm.ssmsette.ssm_sette.Version2.ScrollingActivity"
    tools:showIn="@layout/activity_scrolling_settings">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="90dp"
        android:orientation="vertical">

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtUser"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Server"
                    android:textColor="@color/green_sette_dark" />

                <EditText
                    android:id="@+id/edtUsername"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:ems="10"
                    android:inputType="textPersonName" />
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="20dp"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtSenha"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Port"
                    android:textColor="@color/green_sette_dark" />

                <EditText
                    android:id="@+id/edtPassword"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:ems="10"
                    android:inputType="text"
                    android:text="80" />
            </LinearLayout>
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginEnd="22dp"
            android:layout_marginTop="10dp">

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_centerInParent="false"
                android:layout_marginLeft="20dp"
                android:layout_marginStart="20dp"
                android:text="Protocol"
                android:textAlignment="center"
                android:textColor="@android:color/background_dark" />

            <CheckBox
                android:id="@+id/checkSaveCredentials"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_weight="1"
                android:text="Use https" />

        </RelativeLayout>

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

            <Button
                android:id="@+id/btnSave"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="275dp"
                android:background="@android:color/transparent"
                android:text="Save" />
        </LinearLayout>

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

So, could anyone experienced in Android guide me here? What should I use and how? If I should and have to re-do the layouts on another way I would too. And if someone thinks I should use fragments, could it please guide me?

Community
  • 1
  • 1
BlitzkriegBlue
  • 101
  • 2
  • 14

1 Answers1

1

You want to complete your Signin in two steps

you can use viewpager

Elsunhoty
  • 1,609
  • 14
  • 27