Search code examples
androidandroid-layoutandroid-widgetandroid-relativelayout

Relative Layout alternative for weighted Layout


Is it possible to do a 1:3:6 weight adjustment using relative layout?

I have a relative layout and I need to place 3 UI components inside it using the ratio 1:3:6. Is it possible to do so?


Solution

  • Insert a linear layout (vertical or horizontal depending on your needs) inside this RelativeLayout, deciding its position as usual. And the inside the LinearLayout assign weights to the three elements to the ratio you want.

    They will fill the LinearLayout while giving you the ability of placing it relatively in your layout.