Inserting progressbar on button click

I have this XML and I'm planning that when the login button is clicked, it disappears and the progress bar shows up. how can I do it? this is the image of the XML already made. I've tried dozen of layout edits but still cannot achieve such. I hope someone could help as soon as possible. If there are any suggestions that you can tell please do help.

<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"
    android:background="@color/logregbackground"
    tools:context=".Login.LoginRegister">

    <ImageView
        android:id="@+id/mainformBackground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:scaleType="centerCrop"
        android:src="@drawable/darkbackground" />
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:src="@drawable/isalonlogowithoutbackground"
        android:id="@+id/mainformLogo"
        android:scaleType="fitCenter"
        android:layout_marginBottom="30dp"

        />

    <ScrollView
        android:id="@+id/scrollviewid"
        android:layout_width="match_parent"
        android:clickable="true"
        android:layout_height="wrap_content"
        android:layout_below="@id/mainformLogo"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:background="@drawable/trans_white_rectangle"
            android:layout_marginStart="30dp"
            android:layout_marginEnd="30dp"

            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Welcome to iSalon"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold"
                android:layout_marginBottom="5dp"
                android:paddingStart="10dp"
                android:paddingEnd="10dp"
                android:paddingTop="10dp"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Style on the go, Wherever you go"
                android:textColor="@color/white"
                android:textSize="12sp"
                android:layout_marginBottom="30dp"
                android:paddingStart="10dp"
                android:paddingEnd="10dp" />
                <AutoCompleteTextView
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:hint="Email/Username"
                    android:background="@drawable/rounded_white"
                    android:layout_marginStart="15dp"
                    android:layout_marginEnd="15dp"
                    android:drawableLeft="@drawable/ic_user_icon"
                    android:textSize="14sp"
                    android:drawablePadding="5dp"
                    android:paddingStart="10dp"
                    android:id="@+id/loginUser"
                    android:layout_marginBottom="10dp"
                    android:paddingLeft="10dp" />
            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="Password"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_pass_icon"
                android:textSize="14sp"
                android:inputType="textPassword"
                android:drawablePadding="5dp"
                android:paddingStart="10dp"
                android:id="@+id/loginPass"
                android:paddingLeft="10dp" />

            <Button
                android:id="@+id/buttonLogin"
                android:layout_width="150dp"
                android:layout_height="match_parent"
                android:textColor="@color/white"
                android:text="Login"
                android:textStyle="normal"
                android:layout_gravity="center"
                android:background="@drawable/login_button"
                android:layout_marginTop="16dp"
                android:padding="8dp"
                />

            <ProgressBar
                android:id="@+id/loadinglogin"
                android:layout_width="124dp"
                android:layout_height="27dp"
                android:layout_marginLeft="100dp"
                android:background="@color/white" />
            <Button
                android:id="@+id/buttonRegister"
                android:layout_width="150dp"
                android:layout_marginTop="10dp"
                android:layout_height="match_parent"
                android:textColor="@color/white"
                android:layout_gravity="center"
                android:text="Register"
                android:background="@drawable/register_button"
                android:padding="8dp"
                android:layout_marginBottom="16dp"/>

        </LinearLayout>

    </ScrollView>

</RelativeLayout>

The XML output

Upvotes: 0

Views: 59

Answers (1)

LarsH
LarsH

Reputation: 27994

If you don't want the progress bar to be visible at first, you need to give it a "gone" visibility attribute in the layout (or in your onCreate code):

android:visibility="gone"

That would explain why your progress bar is visible before the login button is clicked.

If your login button isn't disappearing when it's clicked, I don't know why. You'd probably have to show your code.

Upvotes: 1

Related Questions