Android app screen capture 533*320

Source: Internet
Author: User


In our android development, we often use the screen size to determine the ui or other purposes.
In some cases, incorrect values can be obtained by obtaining the width and height of the screen based on different models. (Unit differences and mobile phone manufacturers are different)
Two days ago, it was found that 800*480 was taken from a 533*320 mobile phone in the program, but some were normal. I don't know whether to pass "pixs = dips * (density/160 )"
. If you also encounter this problem, you can use the following code to solve it: (if not, I do not know)
1.
Display display = getwindowmanager (). getdefaultdisplay ();
// Int Height = display. getheight ();
// Int width = display. getwidth ();
Displaymetrics dm = new displaymetrics ();
Dm = getresources (). getdisplaymetrics (); // If the obtained height and width values are inconsistent with the actual values
Display. getmetrics (DM );
Int heightpixels = DM. heightpixels;
Int widthpixels = DM. widthpixels;

2.
Add this configuration in manifest
<Supports-screens
Android: smallscreens = "true"
Android: normalscreens = "true"
Android: largescreens = "true"
Android: resizeable = "true"
Android: anydensity = "true"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.