I’ve written a custom view where I draw myself. I need this because I have to draw circles with borders where as this borders and some stuff within.
At the moment I use 5px as width of the circle borders. This looks OK on ldpi screens, good on mdpi screens and I think it’ll looks crappy on hdpi screens.
How should I write the view to scale the border for different screens? At the moment the custom view gets a attribute which sets the width in pixel.
How can I use other dimensions in the drawing process?
Think in dp, instead of pixel, and obtain pixel corresponding to a dp value using the following code:
Or, if you have defined a dimension in an xml resource file, like this one:
you can obtain pixel value of this dimension with