2

is PercentRelativeLayout replacement of LinearLayout weights ? probably yes.

but how can we make sure that we have optimized our app if we remove linear layouts and reduce layout hierarchy by replacing linear layout with percent relative layout and by removing weight attribute from views but add percentWidth and percentHeight instead of using weights.

Developine
  • 12,483
  • 8
  • 38
  • 42
  • Layout heirachary and weights/percents are different things. The first is about nested views, the other is about layouts at the same level. Probably the only way you know you've optimized them, is to visually inspect them – OneCricketeer Apr 20 '16 at 13:09
  • Possible duplicate : http://stackoverflow.com/questions/34908551/percentrelativelayout-is-more-performant – Ispas Claudiu Apr 20 '16 at 13:10
  • yes i already checked this questions, but answers over there are not detailed and satisfactory. – Developine Apr 20 '16 at 13:11
  • Try reading this: http://developer.android.com/training/improving-layouts/optimizing-layout.html. It doesn't say about percentRelativeLayout but it clearly says that nested LinearLayouts are not performant at all. If you want to see the loading time execution of the layout you can just place some logs with timestamps; one in on create and one in ViewTreeObserver in onGlobalLayout callback (when the layout it is drawn). Making the differences between those two stamps will show you the "interface loading time". – Ispas Claudiu Apr 20 '16 at 13:16

1 Answers1

1

we can not optimize by replacing it with percentRelative layout as because there will same number of tags for both e.g 50,50 is two parts of 100 so I think both are same in this case.

Muhammad Noman
  • 1,842
  • 19
  • 14
  • 1
    but hierarchy will be minimized if we use percentRelativeLayout. because our parent will be relative and we can set views on top/left/bottom. am i right ? – Developine Apr 20 '16 at 13:14
  • yes you can use top left bottom but in inner views the case will be same if you use relativeLayout in division – Muhammad Noman Apr 20 '16 at 13:17