Evenly spacing views using ConstraintLayout

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

    You shoul read about weighted chains. An example of code is here.

    
    
        
    
        
    
        
    
        
    
    

    So, set android:layout_width="0dp", app:layout_constraintHorizontal_weight="1" and link every view with neighbours like:

    app:layout_constraintStart_toEndOf="@id/figure_2"
    app:layout_constraintEnd_toStartOf="@id/figure_4"
    

提交回复
热议问题