I think the title is pretty explicit about my problem... So here is my layout :
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/button_action" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" /> <ProgressBar android:id="@+id/progress_bar" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerInParent="true"/> </RelativeLayout>
On android SDKs < 21, no problem, the ProgressBar is correctly displayed over the Button and centered in the Button. But on Android 5.0, the ProgressBar is displayed behind the Button.
So you can see it's correctly positionned it when you activate the option "Show layout bounds" in Developer Options settings, but you can't see anything on the screen without that option.
Would anybody know how to fix this? I guess it's a matter of elevation recently introduced, but I really don't know how to take care of it. For the record, I'm using the recently released Theme.AppCompat style from the support.v7.
EDIT:
I also tried to apply setElevation(0)
and setTranslationY(0)
to the Button programmatically but it didn't change anything. So I wonder if it has to deal with the elevation.
So let’s see what is Android Progress Bar. Progress bar is a user interface control that shows the progress of any operation. The operation includes downloading a file, copying a file or moving a file. It is like a graphical representation of an indicator that shows the progress of some process or operation.
android: progress – It sets the default progress of the progress bar, which can be set from 0 to max. android:interpolar – It is used to set an acceleration curve for the indeterminate progress bars. android: min – It defines the minimum value for the progress bar. android: progressTint – It applies Tint on progress indicator in the progress bar.
So since you needed ProgressBar on top you need not do the kind of manipulations you are doing. All the three values here are absolute which is a strict no-no as far as Android is concerned. Most Likely your paddingBottom was pushing your ProgressBar out of View. As your padding is greater than the actual width/height of the control
android: max – It sets the maximum value of the progress bar. android: progress – It sets the default progress of the progress bar, which can be set from 0 to max. android:interpolar – It is used to set an acceleration curve for the indeterminate progress bars. android: min – It defines the minimum value for the progress bar.
You can add the android:translationZ
attribute to the ProgressBar
:
<ProgressBar android:id="@+id/progress_bar" android:layout_width="50dp" android:layout_height="50dp" android:translationZ="2dp" android:layout_centerInParent="true"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With