View with minHeight in ConstraintLayout

后端 未结 3 1331
天命终不由人
天命终不由人 2020-12-30 03:46

I have a ConstraintLayout inside a NestedScrollView. The ConstraintLayout contains a bunch of views but the last View can

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 04:10

    Add this attribute to the view you'd like to have stretch:

    app:layout_constraintHeight_default="spread"
    

    I made a tiny app to demonstrate. No java logic to speak of, but here's the layout:

    
    
    
        
    
            
    
            
    
            
    
        
    
    
    

    The bottom view stretches to fill the viewport when it is smaller than the remaining available space, and scrolling is impossible:

    The bottom view maintains a fixed height when it is larger than the remaining available space, which makes scrolling possible:

提交回复
热议问题