简体   繁体   中英

Android getHeight returns a wrong value

I've got a class where i draw some line with canvas. In this class i want to use the height and the width of the screen. But there is a problem. I have a device with a scren 480x800. But when i call the function getWidth() and getHeight() so:

height = getHeight();
width = getWidth();

The width is correct because the width value is 480. But the height value is 483, and should be 800. Does anyone know why?

when you use getHeight(); in your view it give you height of your view no height of screen .see this link Get screen dimensions in pixels

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM