Issue
I read two articles about this topic, this and href="https://stackoverflow.com/questions/27216080/how-to-bring-imageview-in-front-of-button-in-android-5">this.
But both tell solutions like changing the elevation or translations.
The question is about bringing a Progress bar in front of a button in older versions that don't support elevation or translation attributes.
How can I do this in XML and in Java?!
Or it is not valid.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.business.abdelhafiz.omar.civiltaif.LoginActivity">
<ImageView
android:src="@drawable/home_civil"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/login_progressbar"
android:layout_centerInParent="true"
android:layout_width="@dimen/image_height"
android:layout_height="@dimen/image_height" />
<Button
android:id="@+id/login_email"
android:layout_centerInParent="true"
android:text="@string/login_email"
android:onClick="loginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/login_anonymous"
android:layout_centerInParent="true"
android:layout_below="@id/login_email"
android:text="@string/login_anonymous"
android:onClick="loginAnonymous"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Here is a screen shot
I want to bring the progress bar in front of the buttons
Edit:
Nothing worked for me so I will just hide the buttons when I need to show the progress bar.
Thanks for your help.
Solution
you can move it to the bottom like this
<ImageView
android:src="@drawable/home_civil"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/login_email"
android:layout_centerInParent="true"
android:text="@string/login_email"
android:onClick="loginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/login_anonymous"
android:layout_centerInParent="true"
android:layout_below="@id/login_email"
android:text="@string/login_anonymous"
android:onClick="loginAnonymous"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/login_progressbar"
android:layout_centerInParent="true"
android:layout_width="@dimen/image_height"
android:layout_height="@dimen/image_height" />
or in onCreate
method just write login_progressbar.bringToFront();
Answered By - Vasileios Pallas
Answer Checked By - Terry (JavaFixing Volunteer)