convert Dp To Pixels via Context - Android android.content

Android examples for android.content:Context

Description

convert Dp To Pixels via Context

Demo Code

import android.content.Context;

public class Main {

  public static float convertDpToPixels(float dp, Context ctx) {
    return dp * (ctx.getResources().getDisplayMetrics().densityDpi / 160f);
  }//from   w w  w  .  ja  va2 s.  c  o m

}

Related Tutorials