Evenly spacing views using ConstraintLayout

后端 未结 5 1878
悲&欢浪女
悲&欢浪女 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:22

    Well if it helps someone

    the key is here app:layout_constraintHorizontal_weight="1" and
    the best thing about constraint layout is that it supports circular dependency and here this is what I have done using exactly that.

    For first child
    app:layout_constraintEnd_toStartOf="@+id/textInputSecondChild"

    For second child

    app:layout_constraintLeft_toRightOf="@+id/textInputFirstChild"

    here is the complete demo

    
    
        
    
    
    
    
        
    
    
    
    
        
    
    

提交回复
热议问题