You can implement a helper method that you can use to request calculations based on the device's dpi.
Based on @MitulNakum answer from this qustion, do this:
//note that mdpi is the standard
float getAdjustedDimension(float value){
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch(metrics.densityDpi){
case DisplayMetrics.DENSITY_LOW:
//api 4 and higher
return 0.75 * value;
case DisplayMetrics.DENSITY_MEDIUM:
//api 4 and higher
return value;
case DisplayMetrics.DENSITY_HIGH:
//api 4 and higher
return value * 1.25;
case DisplayMetrics.DENSITY_XHIGH
//api 9 and higher
return value * 2;
case DisplayMetrics.DENSITY_TV
//api 13 and higher
return value * 1.33125;
}
}