title: Most Accurate Measurements Possible - Android
body: <p>I'm trying to create an accurate ruler on Android for any device and I've run into a problem. Basically, my measurements are too far off for my two different devices. I expected this to be the case but not for the degree that it's happening. </p>
  
  <p>Currently for onTouchEvent I just print the x location in inches with the following code </p>
  
  <pre><code>    DisplayMetrics metrics = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(metrics);
      float x = event.getX()/metrics.xdpi;
      System.out.println(x);
      return true;
  </code></pre>
  
  <p>and I'm getting the following results</p>
  
  <p><a href="http://imgur.com/S85Kmsr" rel="nofollow">http://imgur.com/S85Kmsr</a>  (3.01 should be 3.10)</p>
  
  <p>Basically, my emulator is constantly .1 inchs off and my galaxy s5 continuously goes up by about .5 inchs</p>
  
  <p>For these results, I'm using a marker width of 1dp and a marker separation of 8 dp. This gives me the most accurate results on my s5.</p>
  
  <p>10dp is 0.625 inchs which is how far an inch should be separated between each marker. </p>
  
  <p>Despite 1dp width and 8dp separation giving me accurate results on my S5, 1dp width and 9dp separation(what it should probably be) gives me perfect results on the android emulator. However, on my S5 the measurements are off by 0.16 inchs per inch.</p>
  
  <p>I'm honestly lost on what to do. I want this to be as accurate as possible between all devices.</p>