Constraint Layout Vertical Align Center

后端 未结 7 983
醉梦人生
醉梦人生 2020-12-13 05:20

How to vertically align and center objects in constraint layout? It is possible to align vertically or horizontally but I have not found a way to center at the same time bes

7条回答
  •  自闭症患者
    2020-12-13 05:50

    It's possible to set the center aligned view as an anchor for other views. In the example below "@+id/stat_2" centered horizontally in parent and it serves as an anchor for other views in this layout.

    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
    
    

    Here's how it works on smallest smartphone (3.7 480x800 Nexus One) vs largest smartphone (5.5 1440x2560 Pixel XL)

提交回复
热议问题