Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RelativeLayout vs LinearLayout with weights

I have a row in a list that I am trying to implement. I can use one RelativeLayout or one LinearLayout with weights. Is there a clear winner in performance for one RelativeLayout or one linearLayout with weights?

like image 363
roiberg Avatar asked Dec 09 '13 13:12

roiberg


People also ask

Which has better performance LinearLayout or RelativeLayout?

Save this answer. Show activity on this post. Unless you're laying out lots of Views (e.g. in a ListView), the performance of choosing between LinearLayout or RelativeLayout is negligible. Pick whichever is most convenient to use for the job, and worry about performance only when you need to.

Can we use weight in RelativeLayout?

RelativeLayout does not pay attention to android:layout_weight . (That's a property of LinearLayout.

What is the difference between LinearLayout and RelativeLayout?

LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions.

Is RelativeLayout deprecated?

relativelayout is deprecated now.


1 Answers

It actually depends on what you are trying to implement. If this is just a content of a row from ListView, I would prefer LinearLayout with weights. There are good answers from this question about using RelativeLayout or LinearLayout, which is related to your's:

Is a RelativeLayout more expensive than a LinearLayout?

like image 190
Yuriy Yunikov Avatar answered Oct 15 '22 02:10

Yuriy Yunikov