This is a most important thing of application development. we know that in the market available different sizes of smartphones and also different their resolution.
When we create a linear or any widgets in the app project set sizes in dp. for example look code below
This is a linear code of Java project if analys the code about height than we found the height is 250dp. this size of linear may take half place of screen in some device for example 5inch display and 720 resolution smartphones but it’s not same size in the all device. may be it’s take more than half place of screen in 4inch display of devices and also may be taken less than half of screen in 6inch display devices. it’s a big problem. for apps developer’s to create best and comfort size for all device.
So what is the solution?
The solution is here yes you can use weight property for set sizes of any widgets or linear. it’s automatic observe screen resolution and devide same size of every screen of devices. for example i write a code below with weight property
In this code i set the height “wrap_contant” and set weight “1“. weight 1 means in the screen size linear is automatic observe screen size and fit same place on every screen size.