浸像素转换的结果完全相同的价值 [英] Dip to pixel conversion results in the exact same value
问题描述
我想逢低转换为使用下面的函数的像素。我试过低,中,高密度模拟器也不管我用的仿真器,像素值保持相同的值沾我的价值传递到函数。
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?
推荐答案
这是我自己的错。模拟器基本上骗来的系统,并告诉我的应用程序是分辨率XY。什么是应该根据支持Android屏幕说明文件的所有部分。我需要正确设置正确的文件夹内的资源,使其不再骗我的应用程序。
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.
这篇关于浸像素转换的结果完全相同的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!