XML : Hardcode layout params into XML or implement programatically in code for consistent UI?

I want to ensure a consistent UI across all screen sizes. I'll use the bottom margin as an example. Let me illustrate with the picture below:

enter image description here

I could hardcode 50dp into the xml for the bottom margin as shown in the picture and treat it as a "middle ground" between large and small devices. Or, I could determine dynamically on runtime the parent view's height, and then multiply it with, say, 10 % and then implement it that way although it's a bit more of a hassle. What do you recommend?

No comments:

Post a Comment