Equally spaced four images using constraint layout

前端 未结 4 440
庸人自扰
庸人自扰 2021-01-15 05:54

i want to equally spaced four images using constraint layout...i have used guidelines but it is giving me a lot of space between the images and right corner images are going

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 05:59

    Not sure about your exact requirement from question, but I can see that you need to display 4 squares with equal width & height across devices.

    You don't need to use guideline for both vertical and horizontal but instead to distribute it vertically you can use barrier to align them properly.

    Check out code below:

    
    
    
        
    
        
    
        
    
        
        
        
    
        
    
        
    
        
    
    

    Output:

    (This will be consistent across different screen sizes)

    Here, vertical guideline is used to distribute views evenly on horizontal direction while barrier is used to align two views in vertical direction.

    Dimension ratio is used to make square consistent with 0dp as height & width.

    Edit: O.P. seeks for solution on arranging entire view hierarchy with square boxes at bottom, given below is complete code:

    
    
    
        
    
            
    
            
    
            
    
            
    
            
    
            
    
            
    
            
    
            
    
            
        
    
        
    
    
    

提交回复
热议问题