0

I have looked for question on this website and through google but there are no easy ways to set the size of the a View proportional to the parent.

Since android is a language that runs on devices of many screen densities and sizes it would make sense to have an easy to use method to set the size of views based upon the parent such as: 0.5*match_parent

I found some solutions but none of them are simple single lines that you would expect would be built into android, since every android app needs to support many screen sizes.

Is there some restriction because of the way activities are built? Is it inefficient to have to retrieve the size of the parent?

JFreeman
  • 974
  • 1
  • 10
  • 26
  • please provide what you've tried, because with linear layout you just need to add 2 lines, weightSum="", and layoutWeight="", and even you can do with without weightSum, just write LayoutWeight="0.5" and change the width or height respectively based on the linearlayout's orientetion. – Achmad Naufal Syafiq Jan 29 '18 at 06:44

1 Answers1

1

Now it is possible to set size proportional to parent. The Constraint Layout

allows to do it.

Check this answer for more details

AloDev
  • 410
  • 3
  • 13