Android - Constraint layout - How to align a view centered over edge of other view?

前端 未结 2 1506
北恋
北恋 2021-02-05 03:42

I want to build a layout like this:

Inside the constraint layout there is an Image View which acts like a banner, then there is a Card that is center aligned wi

2条回答
  •  你的背包
    2021-02-05 03:51

    Try this:

    
    
    
        
    
        
    
    
    

    Explanation :- This works because of these four lines

    Following lines sets the blue CardView centered on the bottom edge of White CardView.

    
    app:layout_constraintTop_toBottomOf="@+id/card_1"
    
    
    app:layout_constraintBottom_toBottomOf="@+id/card_1"
    

    Following lines set the blue CardView centered horizontally

    
    app:layout_constraintLeft_toLeftOf="@+id/card_1"
    
    
    app:layout_constraintRight_toRightOf="@+id/card_1"
    

提交回复
热议问题