Why does Progressbar hide behind the button?

Asked

Viewed 173 times

1

I created a RelativeLayout with a button and a circular Progressbar. This way below:

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal">

  <Button
    android:id="@+id/btnLogin"
    android:theme="@style/ButtonStart"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/login" />

  <ProgressBar
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="14dp"
    android:layout_marginStart="14dp"
    android:id="@+id/progressBar4"/>

</RelativeLayout>

Independent of the order, inserting first the Button and then ProgressBar, or vice versa, after the compiled project, the ProgressBar always stands behind the button. Why the ProgressBar hides behind the button? What better way to solve this problem?

  • I believe that for simple layouts like yours, a Framelayout is enough.

  • @Leonardolima with Framlayout remains the same problem. Maybe the link you posted, may even bring some solution. But the interesting thing would be to bring this kind of content to Sopt.

1 answer

0

The problem is you’re not saying about what Progress should be.

Just add android:layout_below="@id/btnLogin" and the magic will come true.

Another option would be to use one LinearLayout guided vertical.

  • That’s not the problem. Progressbar is in the same position as the button. I don’t want to put the file below. I want it to be in front of the button, on the button. That’s why I’m using Relativelayout.

Browser other questions tagged

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