Ponga una barra de progreso circular sobre mi forma de la conexión

Abraham Arreola :

He diseñado este formulario de acceso simulando la página de facebook de inicio de sesión para el movil. Yo uso los servicios de Internet para hacer solicitudes desde la aplicación a una API:

diseño de formulario de acceso

Lo que quiero hacer es poner una barra de progreso circular mientras la solicitud esté ejecutando, quiero desactivar todos los componentes, y poner la barra de progreso cicular sobre la forma y una vez que la solicitud ha sido atendida, active de nuevo todos los componentes. Este es mi código XML:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#dfe1ee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:context="com.example.abrahamarreola.facebooklogin.LoginScreen">

    <LinearLayout
        android:background="#3b5998"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:src="@drawable/facebook_logo"
            android:layout_width="match_parent"
            android:layout_height="50dp" />
    </LinearLayout>

    <LinearLayout
        android:background="#E3CE3B"
        android:paddingBottom="2dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:textColor="#8f8b59"
            android:textStyle="bold"
            android:background="#fffacd"
            android:textAlignment="center"
            android:textSize="16dp"
            android:text="Log in to use your Facebook account"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:paddingRight="20dp"
        android:paddingLeft="20dp"
        android:paddingBottom="20dp"
        android:paddingTop="30dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:background="@drawable/back1"
            android:orientation="horizontal"
            android:paddingBottom="10dp"
            android:paddingTop="10dp"
            android:paddingRight="12dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:layout_width="45dp"
                android:layout_height="40dp"
                android:src="@drawable/celphone_icon" />

            <TextView
                android:textStyle="bold"
                android:textSize="14dp"
                android:elegantTextHeight="true"
                android:textColor="#3b5998"
                android:layout_gravity="center_vertical"
                android:gravity="center"
                android:text="Use Facebook in your device everywhere."
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:padding="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:paddingTop="8dp"
            android:orientation="vertical"
            android:background="@drawable/back2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/email_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.design.widget.TextInputEditText
                    android:id="@+id/email_input"
                    android:singleLine="true"
                    android:paddingLeft="20dp"
                    android:hint="Email:"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:id="@+id/password_layout"
                app:passwordToggleEnabled="true"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.design.widget.TextInputEditText
                    android:id="@+id/password_input"
                    android:inputType="textPassword"
                    android:singleLine="true"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:hint="Password:"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </android.support.design.widget.TextInputLayout>

            <LinearLayout
                android:padding="10dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <Button
                    android:id="@+id/login_button"
                    android:textSize="16dp"
                    android:textColor="#ffff"
                    android:textStyle="bold"
                    android:text="Log In"
                    android:background="@drawable/button_login"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

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

        <LinearLayout
            android:orientation="vertical"
            android:paddingTop="20dp"
            android:paddingLeft="70dp"
            android:paddingRight="70dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <Button
                android:id="@+id/new_account_button"
                android:layout_gravity="center"
                android:textSize="16dp"
                android:textColor="#ffff"
                android:textStyle="bold"
                android:text="Create new account"
                android:background="@drawable/button_create_account"
                android:layout_width="200dp"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/help_label"
                android:textColor="#808cba"
                android:layout_gravity="center"
                android:paddingTop="10dp"
                android:text="Forgotten Password? - Help Centre"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:background="#ffff"
            android:layout_gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="40dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Facebook ©2019"
                android:textAlignment="center"
                android:textSize="16dp" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
Sumit Shukla:

Usted puede hacer uso del ProgressDialoglugar de ProgressBar para la sencilla purposes.On el clic de su register buttonuso ProgressDialogcomo esto:

 ProgressDialog dialog = new ProgressDialog(YourActivity.this);    
 dialog.setMessage("Registering...");
 dialog.setCancelable(false);
 dialog.setCanceledOnTouchOutside(false);
 dialog.show();

Para descartar de diálogo cuando tienes éxito o el fracaso de respuesta:

dialog.dismiss();

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=236482&siteId=1
Recomendado
Clasificación