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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With