Assign width to half available screen width declaratively

前端 未结 5 2173
北恋
北恋 2020-11-28 23:43

Is it possible to assign a widget width to half the available screen width, and do it using declarative xml?

5条回答
  •  佛祖请我去吃肉
    2020-11-29 00:11

    Using constraints layout

    1. Add a Guideline
    2. Set the percentage to 50%
    3. Constrain your view to the Guideline and the parent.

    If you are having trouble changing it to a percentage, then see this answer.

    XML

    
    
    
        
    
        
        
    
    

提交回复
热议问题