Java tutorial
//package com.java2s; import android.content.res.Resources; public class Main { public static int animateContainerExtraTopOffset(Resources resources) { float density = resources.getDisplayMetrics().density; if (density >= 4.0) { return 0; } if (density >= 3.0) { return 0; } if (density >= 2.0) { return 1; } if (density >= 1.5) { return 2; } if (density >= 1.0) { return 2; } return 0; } }