Tuesday, 9 December 2014

Converting from dips to pixels

Useful bit of C# Xamarin code for converting from dips to pixels:
            var dpValue = 10; // value in dips
            var d = AppContext.Resources.DisplayMetrics.Density;
            var pixValue = (int)(dpValue * d); // value in pixels

No comments:

Post a comment

Comments are moderated, so you'll have to wait a little bit before they appear!