Best practice for defining width & height for Android UI elements

I read in some posts that it’s better to define ui elements in xml and not programmatically, and also that I should use dp units inside xml, so I wonder now how can I determine which fixed values should I use ?

Let’s say I want to have an ImageView with a width that is 1/3 of the screen’s width. Is there an offline way to find the dp number I should specify inside the xml or should I still set the height & width programmatically ?


Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.