PercentRelativeLayout is more Performant?

允我心安 提交于 2019-12-03 22:34:13
Jeroen Mols

Looking at the source code, a PercentRelativeLayout is basically a minor extension of a RelativeLayout. This means you need to make the same considerations as when you choose between a RelativeLayout and LinearLayout.

  • RelativeLayout needs 2 measure passes -> avoid using it as the root of a deep view hierarchy or nesting multiple RelativeLayouts (more info in this stackoverflow post)
  • Layout weights in LinearLayout also require 2 measure passes -> try to replace these constructs as much as possible with one Relative/GridLayout (more info in this stackoverflow post)

Finally it is worth noting that:

  • Don't optimise unless you have a problem
  • Try to keep your hierarchies as flat as possible
PercentRelativeLayout 

is just a extension of RelativeLayout so i think:

1) u should use it in case of nested weights with linearlayout as they are bad for performance

2)No,but depends on your useCase. For ex:-it has less performance than LinearLayout and RelativeLayout but more than LinearLayout with nested weight

Also u can refer this post from android developer: http://developer.android.com/training/improving-layouts/optimizing-layout.html

Try PercentRelativeLayout and PercentFrameLayout of Percent Support Library

http://android-er.blogspot.in/2015/08/try-percentrelativelayout-and.html

here you can find best comparison for both layouts.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!