Convert meter To Pixel - Android android.location

Android examples for android.location:Distance

Description

Convert meter To Pixel

Demo Code

public class Main {

  static float sPixelDensity = -1f;
  public static int meterToPixel(float meter) {
    // 1 meter = 39.37 inches, 1 inch = 160 dp.
    return Math.round(dpToPixel(meter * 39.37f * 160));
  }/*from  w ww  .  ja v a 2  s . c  o  m*/

  public static int dpToPixel(int dp) {
    return Math.round(dpToPixel((float) dp));
  }

  public static float dpToPixel(float dp) {
    return sPixelDensity * dp;
  }

}

Related Tutorials