RobGThai
RobGThai

Reputation: 5969

How to avoid nested weights when creating Android layout?

I'm prone to abusing LinearLayout, every screens there's usually three or four-level deep. Layout's design usually given size in percentages. Graphic cut to pieces and not utilizing 9-Patch. All of these resulting in me using layout_weight to represent percentages almost everywhere. Today I updated ADT and Lint has this nested weights warning everywhere. Now I'm really concern about the performance if I carry this habit into a bigger application. Is there a better way to do it without changing anything from designer's side?

Upvotes: 0

Views: 991

Answers (1)

FoamyGuy
FoamyGuy

Reputation: 46856

If I start to get too many layers of LinearLayouts I tend to switch to a RelativeLayout at the root and most of the children only 1 layer removed from root.

9-Patch resources are very helpful also. I suggest you start to make use of those more.

Upvotes: 2

Related Questions