Android 5.0 - ProgressBar cannot be displayed over a Button

后端 未结 6 1762
孤城傲影
孤城傲影 2020-12-11 00:04

I think the title is pretty explicit about my problem... So here is my layout :

            

        
6条回答
  •  囚心锁ツ
    2020-12-11 00:18

    Same question being asked here, with a better explanation of the issue:

    https://stackoverflow.com/a/27216368/235910

    To quote @CommonsWare:

    The problem appears Android 5.0's elevation property. Apparently, the RelativeLayout Z-axis ordering is tied into elevation. If both widgets have the same elevation, the RelativeLayout will determine the Z-axis order -- you can see that if you were to switch your layout to be both Button widgets, for example. However, if one widget (Button) has an elevation, and another widget (ImageView) does not, the elevation will take precedence.

    You can remove the Button elevation via android:stateListAnimator="@null" or by defining your own custom animator. Or, you can add some elevation to your ImageView to get it to be higher on the Z axis than is the Button.

提交回复
热议问题