Android: Overlapping two views (intentionally!)

前端 未结 3 1225
萌比男神i
萌比男神i 2021-02-05 18:26

just wondering is it possible to overlap two elements?

This is an illustration of what im trying to achieve:

3条回答
  •  粉色の甜心
    2021-02-05 18:54

    You can use a RelativeLayout for the blue box, align your ImageView to the top-right corner, and then use negative margins to push it over the bounding box. Here's a sample illustrating the general idea:

    
    
    
    
        
    
    

    EDIT: I played with this a bit more, and you have to set android:clipChildren="false" on the parent of the RelativeLayout. Here's a more complete sample:

    
        
            
        
    
    

提交回复
热议问题