Evenly spacing views using ConstraintLayout

后端 未结 5 1879
悲&欢浪女
悲&欢浪女 2020-11-28 18:08

A common use for LinearLayout is to evenly space (weight) views, for example:

How do you implement evenly spaced views like this using the new ConstraintLayou

5条回答
  •  粉色の甜心
    2020-11-28 18:24

    To create 2 views in same line, equal width, just need to define

    
    
        

    Note

    • width = 0dp (MATCH_CONSTRAINT)
    • Constraint of button1 and button2 must like above

    Result

    MORE
    If you want View1 bigger than View2 you can use weight or percent.
    Example, View1 width = 2 *View2 width use weight

    
    
        

    Result

    Example, View1 width = 2 *View2 width use percent

    
    
        

    Result

提交回复
热议问题