5

I am trying to convert dips to pixels using the following function. I’ve tried low, medium, and high density emulators and regardless of the emulator I use, the pixel value remains the same value as the dip value I pass into the function.

private int ConvertDips(float dips) {
 int pixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dips, getResources().getDisplayMetrics());
 return pixels;
}

What the heck am I doing wrong here?

alain.janinm
  • 19,951
  • 10
  • 65
  • 112
user432209
  • 20,007
  • 10
  • 56
  • 75

1 Answers1

2

This was my own fault. The emulator was basically lying to the system and telling my app it was resolution x-y. All part of what it was supposed to do according to the Android support screens documentation. I needed to properly set up resources within the correct folders so that it would no longer lie to my application.

user432209
  • 20,007
  • 10
  • 56
  • 75
  • could you please make the answer clear. I am facing the same problem. What do you mean by "setting the resources within correct folder" ? – darsh May 09 '12 at 06:54