After several years of Android development, for several months I wondered why I should use xml layouts to create the user interface of my Android application.
I understand this part of the MVC design and real-time GUI.
If I'm wrong, please take me out of ignorance and forgive me, but I canโt set the view position to exactly 8% of the screen width for the field and 70% of the screen width for the width, for example.
Creating a user interface in this way and observing the proportions of the screen ensures that the application will look proportionally exactly the same on all devices.
As this post sums up, we are told to use dip units and a nice bunch of xml files for each layout of our application, if we want to support different screens. (Why do they call it density independent if we need to make it different for each screen density?)
But even doing it like (again) Google Doc says
The dp-to-pixel ratio will vary with screen density, but not necessarily in direct proportion.
And instead of not necessarily, they should say, basically, never looking at an incredible amount of different devices. This may be a problem depending on your project. (Or do you want your client to look at your "slightly laid out" user interface on those who know the Chinese device).
I could ask the same for image resources, but this will be another question I use to set the maximum resolution to -nodpi, then decrease with the code to the required size depending on the screen width, instead of putting 10,000 images general resolution.
Nanoc source share