开发者

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) TypedValu开发者_开发百科e.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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜