Hide view behind another view in Android

2019-04-25 18:58发布

问题:

I'm trying to get a view to "slide behind" another view. Consider a set of cards as an example: if I put card A behind card B, card A is still there but it is being blocked because card B is OVER or IN-FRONT-OF card A.

I am well aware of setInvisibilty() but that is not the effect I'm looking for.

I have an animation that animates a Google-Now-card-like view onto the screen. The card passes over some text that is shown in front of the card (whereas I want the card to slide above the text) during the animation. I have an alpha animation on the text which does not help as it's already pretty solid by the time the card passes over.

Any response to the problem above or suggestions for a different method are highly appreciated.

回答1:

See this previous question : Defining Z order of views of RelativeLayout in Android

View.bringToFront()

Is what you're looking for.