Good question. But that way you are doing is not how a "professional" developer would do. You do not need 32 layouts for a single Activity, Android is intelligent enough to handle things.
Without multi-definition of layouts/multi-definition of dimens.xml
multi-device support possible or not?
Yes, it is absolutely possible and this is what you should be doing. Defining 32 layouts for a single Activity layout is not a good thing.
Suppose, I have a considerably large app in Play Store with more than 20 Activities, now if I had defined 32 layouts for a single Activity, then there would have been more than 600 layouts for my app. Is that feasible? Just ask yourself.
You need to start by giving this page a very very good read. It contains almost everything you need to know. But I will help you get things right.
You do not need to provide alternative resources for every combination
of screen size and density. The system provides robust compatibility
features that can handle most of the work of rendering your
application on any device screen, provided that you've implemented
your UI using techniques that allow it to gracefully resize
This statement is enough to convince you that you should not be doing this. The Android system is intelligent enough to resize your layout accordingly. And trust me, its really good in that.
As you design your UI for different screen sizes, you'll discover that
each design requires a minimum amount of space. So, each generalized
screen size above has an associated minimum resolution that's defined
by the system. These minimum sizes are in "dp" units—the same units
you should use when defining your layouts
I will try to point out some of the important things you need to consider.
- Never ever hardcode pixels in your layout
- Always use
dp
or sp
in your layouts. As the name suggests, they are independent of the density of different devices, so will look same in every device.
- Always use
wrap_content
or match_parent
for heights and widths
- Never ever use the
AbsoluteLayout
RelativeLayout
or LinearLayout
both would work great for you, you just need to decide which one you want to use depending on the scenario
- Always provide different versions of your drawables for different screen sizes. This is something that you can't skip. If you do not do it, not only will your layout look awful in different devices but it will make your app consume unnecessary resources.
- Though a single layout will work great on tablets too, but as the screen sizes of tables are much larger than that of typical phones, you should provide separate layouts only for them.
Android Studio Rich Layout Editor
Android Studio has an amazing layout editor where you can preview your layout instantly. Just see this screenshot below,
I am previewing a particular screen of my app in a variety of screen sizes all at once and my layout looks just as I wanted it to look, in all of them.
I just have two layouts for this Activity, one for all the phones and one for all the tablets.
Practical Experience
If you want a practical experience, I have an app running on the Play Store which is used by thousands of users on more than 8000 different devices of different screen sizes.
I only have 2 layouts for a particular Activity, one for the phones and one for the tablets. The UI of my app looks good in all devices and I never had a complaint about it from any user. In case if you need, here is the link to the app.
I am sure this detailed answer could clarify all your doubts, if not, do not hesitate to let me know. I would love to help further.
UDPATE
I would try to clear your confusion once again. But firstly I would RECOMMEND you to read my answer more than once.
Either you need one layout or two, it all depends on the particular layout you are designing. All layouts are different from the other. It can't be defined technically as its subjective. There is no thumb rule for it. But I will try to help you formally.
You need to make good use of the Android Studio Rich Layout Editor and its awesome live preview feature.
First try to design the layout targeting any average device size (like 5 inch of Nexus 5). Just choose Nexus 5 to preview your layout.
Once you are satisfied with the design, select other screen sizes to preview them. You can also choose "Preview all sizes" like the screenshot above.
Try to see if your layout looks good in all the screen sizes, varying from a 4 inch to a 10 inch tablet. See if the spacing's, image sizes, font sizes are all correct.
All the phones ranging from 4 inch to 6 inch will generally have perfect previews, but you may need to design an another layout separately for the tablets screens (as they are large enough). Only here comes the need for 2 layouts, but not always.
Like in my app, I have 2 separate layouts only for 5-6 activities, but for the rest I just have a single layout. It all depends on the particular layout.
Designing is a whole lot different from programming. Programming can be defined formally and grammatically, but design can't be. Design is absolutely subjective and depends on the designers perspective. Be creative in your own way, that's the magic of design.