Material ripple effect hidden by other view in layout

后端 未结 4 2074
一个人的身影
一个人的身影 2020-12-05 14:51

I added a ripple effect on a ImageButton, however it is hidden by an ImageView used as a background for the parent view RelativeLayout

4条回答
  •  旧巷少年郎
    2020-12-05 15:37

    I am experiencing same issue. Only solution I have found so far is not 100% okay since ripple is masked by view (its not borderless).

    The solution (workaround): surround your ImageButton with other view and set ripple to the foreground instead of the background in your layout like this:

     
    
    
    
        
    
    

    I would be really glad if someone explain why the ripple is drawn behind the image. Also if you look at Google Photos app, in image detail they have transparent icons over image view with ripple. I would like to replicate this, but I am not able to make the ripple to be in foreground. Does anybody know how to put transparent imagebuttons over everything but still have the ripple?

    EDIT final solution here you can find exactly same question link

    with great explanation what is happening. the solution is the same but on top of that it solves rectangular mask by adding

    android:clipChildren="false"
    android:clipToPadding="false"
    

    to your layout. now your ripple should be borderless (it worked for me). The layout xml could be something like this:

    
    
         
    
        
           
        
    
    
    

提交回复
热议问题