Replace pixels with dp

Asked 2 years ago, Updated 2 years ago, 88 views

I'm building an app with a Pentec device, and the screen resolution is 480x800 But I want to set the resolution of the G1 device I think if you change the pixels to dp, the two devices can provide the same screen Can you change the pixel to dp?

android dpi pixel resolution

2022-09-22 22:35

1 Answers

Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, r.getDisplayMetrics());


2022-09-22 22:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.