How to place a progressbar over the elements

Asked

Viewed 32 times

0

as in the image https://imgur.com/LQy3zAs, the progressbar is behind the elements.

<ImageView
        android:id="@+id/imgModoAuto"
        android:foregroundGravity="center_horizontal"
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
        android:src="@drawable/modo_transito_crop"
        android:layout_height="120dp"/>


<ScrollView
        android:layout_below="@id/imgModoAuto"
        android:layout_width="match_parent"
        android:id="@+id/scrollview"
        android:layout_height="446dp"
        android:layout_marginTop="10dp"
        tools:context=".fragment.LoginFragment">

    <RelativeLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/relative">


        <LinearLayout android:layout_width="match_parent"
                      android:orientation="vertical"
                      android:id="@+id/linearLayout"
                      android:layout_height="match_parent">

            <TextView android:id="@+id/txtLogin"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:text="@string/login"
                      android:textColor="@color/white"
                      android:gravity="center"
                      android:textStyle="bold"
                      android:textSize="20sp"/>

        </LinearLayout>

        <ProgressBar
                android:id="@+id/progress_bar_login"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_centerInParent="true"
                android:visibility="visible" />



        <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/edtEmail"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_below="@id/linearLayout"
                android:layout_width="match_parent"
                android:layout_marginStart="40dp"
                android:layout_marginEnd="40dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/edit_text_box"
                app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
                android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etLogin"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/edit_text_box"
                    android:hint="@string/email"
                    android:textCursorDrawable="@drawable/color_cursor"
                    android:inputType="textEmailAddress"/>

        </com.google.android.material.textfield.TextInputLayout>


        <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/edtSenha"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="match_parent"
                android:layout_marginStart="40dp"
                android:layout_marginEnd="40dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/edit_text_box"
                app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
                android:layout_height="wrap_content"
                app:passwordToggleEnabled="true"
                android:layout_below="@id/edtEmail">

            <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etPassword"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/edit_text_box"
                    android:hint="@string/senha"
                    android:textCursorDrawable="@drawable/color_cursor"
                    android:inputType="textPassword" android:layout_alignBottom="@+id/edtSenha"/>

        </com.google.android.material.textfield.TextInputLayout>

        <Button android:id="@+id/btnEntrar"
                android:layout_width="match_parent"
                android:layout_below="@id/edtSenha"
                android:layout_marginStart="40dp"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="40dp"
                android:text="@string/entrar"
                android:padding="20dp"
                android:textColor="@color/white"
                android:background="@drawable/form_button"
                android:layout_height="wrap_content"/>


        <LinearLayout
                android:id="@+id/relOpcoes"
                android:layout_below="@id/btnEntrar"
                android:layout_width="match_parent"
                android:gravity="center_horizontal"
                android:orientation="horizontal"
                android:foregroundGravity="center_horizontal"
                android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                    android:text="@string/esqueci_senha"
                    android:layout_marginTop="10dp"
                    android:textColor="@color/white"
                    android:id="@+id/btnEsqueceuSenha"
                    android:background="@drawable/form_button_white"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:paddingBottom="15dp"
                    android:paddingTop="15dp"
                    android:layout_marginEnd="20dp"
                    android:layout_height="wrap_content"/>

            <Button android:layout_width="wrap_content"
                    android:id="@+id/btnSignUp"
                    android:background="@drawable/form_button_white"
                    android:text="@string/cadastre_se"
                    android:textColor="@color/white"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:paddingBottom="15dp"
                    android:paddingTop="15dp"/>


        </LinearLayout>




        <TextView android:id="@+id/txtEntrecom"
                  android:layout_width="match_parent"
                  android:text="@string/ou_entre_com"
                  android:layout_centerInParent="true"
                  android:layout_marginTop="10dp"
                  android:textSize="14sp"
                  android:textColor="@color/white"
                  android:gravity="center_horizontal"
                  android:layout_below="@id/relOpcoes"
                  android:layout_height="wrap_content"/>


        <LinearLayout android:layout_width="match_parent"
                      android:layout_below="@id/txtEntrecom"
                      android:orientation="horizontal"
                      android:id="@+id/lilBotoesSociais"
                      android:gravity="center_horizontal"
                      android:layout_height="match_parent">


            <ImageButton
                    android:id="@+id/imbFacebook"
                    android:layout_width="56dp"
                    android:background="@drawable/fab_facebook"
                    android:layout_height="56dp"
                    android:layout_marginTop="10dp"/>


            <ImageButton
                    android:id="@+id/google_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/fab_google"
                    android:layout_marginStart="20dp"
                    android:layout_marginTop="10dp"/>

        </LinearLayout>


    </RelativeLayout>

</ScrollView>

<ImageView
        android:id="@+id/imageDpVat"
        android:layout_below="@id/scrollview"
        android:layout_marginTop="10dp"
        android:background="@drawable/curva_inferior_branca"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

  • In the XML, the last element of the parent node is on top of the others.

1 answer

0

Following @Valdeir Psr’s comment the last parent element overlaps the others. Therefore, simply reposition your circular progress inside the Relativelayout contained in Scrowview to the last position (Last element to be declared). Making your code look like this:

<ImageView
        android:id="@+id/imgModoAuto"
        android:foregroundGravity="center_horizontal"
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
        android:src="@drawable/modo_transito_crop"
        android:layout_height="120dp"/>


<ScrollView
        android:layout_below="@id/imgModoAuto"
        android:layout_width="match_parent"
        android:id="@+id/scrollview"
        android:layout_height="446dp"
        android:layout_marginTop="10dp"
        tools:context=".fragment.LoginFragment">

    <RelativeLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:id="@+id/relative">


        <LinearLayout android:layout_width="match_parent"
                      android:orientation="vertical"
                      android:id="@+id/linearLayout"
                      android:layout_height="match_parent">

            <TextView android:id="@+id/txtLogin"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:text="@string/login"
                      android:textColor="@color/white"
                      android:gravity="center"
                      android:textStyle="bold"
                      android:textSize="20sp"/>

        </LinearLayout>

        <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/edtEmail"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_below="@id/linearLayout"
                android:layout_width="match_parent"
                android:layout_marginStart="40dp"
                android:layout_marginEnd="40dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/edit_text_box"
                app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
                android:layout_height="wrap_content">

            <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etLogin"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/edit_text_box"
                    android:hint="@string/email"
                    android:textCursorDrawable="@drawable/color_cursor"
                    android:inputType="textEmailAddress"/>

        </com.google.android.material.textfield.TextInputLayout>


        <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/edtSenha"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="match_parent"
                android:layout_marginStart="40dp"
                android:layout_marginEnd="40dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/edit_text_box"
                app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
                android:layout_height="wrap_content"
                app:passwordToggleEnabled="true"
                android:layout_below="@id/edtEmail">

            <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etPassword"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/edit_text_box"
                    android:hint="@string/senha"
                    android:textCursorDrawable="@drawable/color_cursor"
                    android:inputType="textPassword" android:layout_alignBottom="@+id/edtSenha"/>

        </com.google.android.material.textfield.TextInputLayout>

        <Button android:id="@+id/btnEntrar"
                android:layout_width="match_parent"
                android:layout_below="@id/edtSenha"
                android:layout_marginStart="40dp"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="40dp"
                android:text="@string/entrar"
                android:padding="20dp"
                android:textColor="@color/white"
                android:background="@drawable/form_button"
                android:layout_height="wrap_content"/>


        <LinearLayout
                android:id="@+id/relOpcoes"
                android:layout_below="@id/btnEntrar"
                android:layout_width="match_parent"
                android:gravity="center_horizontal"
                android:orientation="horizontal"
                android:foregroundGravity="center_horizontal"
                android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                    android:text="@string/esqueci_senha"
                    android:layout_marginTop="10dp"
                    android:textColor="@color/white"
                    android:id="@+id/btnEsqueceuSenha"
                    android:background="@drawable/form_button_white"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:paddingBottom="15dp"
                    android:paddingTop="15dp"
                    android:layout_marginEnd="20dp"
                    android:layout_height="wrap_content"/>

            <Button android:layout_width="wrap_content"
                    android:id="@+id/btnSignUp"
                    android:background="@drawable/form_button_white"
                    android:text="@string/cadastre_se"
                    android:textColor="@color/white"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:paddingStart="20dp"
                    android:paddingEnd="20dp"
                    android:paddingBottom="15dp"
                    android:paddingTop="15dp"/>


        </LinearLayout>




        <TextView android:id="@+id/txtEntrecom"
                  android:layout_width="match_parent"
                  android:text="@string/ou_entre_com"
                  android:layout_centerInParent="true"
                  android:layout_marginTop="10dp"
                  android:textSize="14sp"
                  android:textColor="@color/white"
                  android:gravity="center_horizontal"
                  android:layout_below="@id/relOpcoes"
                  android:layout_height="wrap_content"/>


        <LinearLayout android:layout_width="match_parent"
                      android:layout_below="@id/txtEntrecom"
                      android:orientation="horizontal"
                      android:id="@+id/lilBotoesSociais"
                      android:gravity="center_horizontal"
                      android:layout_height="match_parent">


            <ImageButton
                    android:id="@+id/imbFacebook"
                    android:layout_width="56dp"
                    android:background="@drawable/fab_facebook"
                    android:layout_height="56dp"
                    android:layout_marginTop="10dp"/>


            <ImageButton
                    android:id="@+id/google_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/fab_google"
                    android:layout_marginStart="20dp"
                    android:layout_marginTop="10dp"/>

        </LinearLayout>


        <ProgressBar
                android:id="@+id/progress_bar_login"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_centerInParent="true"
                android:visibility="visible" />


    </RelativeLayout>

</ScrollView>

<ImageView
        android:id="@+id/imageDpVat"
        android:layout_below="@id/scrollview"
        android:layout_marginTop="10dp"
        android:background="@drawable/curva_inferior_branca"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

Just like in the Java class, the xml code is traversed from top to bottom.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.