I always use LinearLayout and RelativeLayouts, and i was reading about the "new" PercentRelativeLayout. I have a few questions:
Should i always start using this one or only in cases of nested weights with linearlayout?
Is this more performant than the others?
Any other information about PercentRelativeLayout it will be welcome.
Thanks!
PercentRelativeLayout class extends from Relative Layout class so it supports all the features, attributes of RelativeLayout and it has percentage dimensions so it also supports some features of LinearLayout. In Simple words we can say that PercentRelativeLayout has features of both Layouts with reduced view complexity.
PercentRelativeLayout is same as relative layout with an additional feature ‘percentage’. we can put percentage on view component (out of 100) in terms of width,height,margins etc. Or simply we can say use relative percent layout as linear layout as it has features of both along with reduced view complexity.
Subclass of RelativeLayout that supports percentage based dimensions and margins. You can specify dimension or a margin of child by using attributes with "Percent" suffix. Follow this example: layout_marginBottomPercent
View centered in another view. If we have to use that view, the best option is FrameLayout. This example also shows that if we can use the simplest layout it’s the best option for our performance. 3. Layout with 2 views on different sides.
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.
Finally it is worth noting that:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With