Why are nested weights bad for performance? Alternatives?

后端 未结 6 1575
深忆病人
深忆病人 2020-11-22 16:26

I have written a couple layout files where I used the layout_weight attribute to create a ratio between different views.

At some point, I start getting

6条回答
  •  抹茶落季
    2020-11-22 16:57

    Update: As we know the percent support library is deprecated from API level 26. ConstraintLayout is the new way to achieve the same flat xml structure.

    Updated Github Project

    Updated Samples:

    
    
        
    
        
    
    
    

    Update: Great news android percent support library solves our problem of performance and nested messy weighted LinearLayout

    compile 'com.android.support:percent:23.0.0'
    

    Demo HERE

    Consider this simple layout to demonstrate the same.

    
        
        
    
    
    

    Avoided performance degrader nested LinearLayout with weights.Really awesome!!!.

提交回复
热议问题