Consider changing your dpToPx conversion to Math.round(dp * (displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)). You are using displayMetrics.xdpi inplace of the device true densityDpi. This had big consequences for us across different devices such as Samsung S9+
Consider changing your dpToPx conversion to Math.round(dp * (displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)). You are using displayMetrics.xdpi inplace of the device true densityDpi. This had big consequences for us across different devices such as Samsung S9+