I had written method to get the pixels from dip but it is not working. It give me runtime error.
Actually I was running this method in separate class and initialized
Try this : For without passing context
public static float dipToPixels(float dipValue) { return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, Resources.getSystem().getDisplayMetrics()); }