ConstraintLayout Flow helper example

后端 未结 1 1451
半阙折子戏
半阙折子戏 2020-12-17 14:45

I have read in a blog entry that in ConstraintLayout 2.0.0, a way was introduced to create a flow of views. What I exactly want to achieve: I have several

1条回答
  •  难免孤独
    2020-12-17 15:22

    You can achieve this by adding a androidx.constraintlayout.helper.widget.Flow virtual view inside the androidx.constraintlayout.widget.ConstraintLayout and by referencing all your textviews with app:constraint_referenced_ids attribute.

    Example below shows how I've achieved it.

    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
    

    Play around with app:flow_ attributes to change the arrangement of the textviews such as alignment, margin, etc. https://developer.android.com/reference/androidx/constraintlayout/helper/widget/Flow

    Final result should look like below depending on your screen size.

    0 讨论(0)
提交回复
热议问题