Android Browser and WebView support the DOM property, which allows you to request the density of the current device - the window.devicePixelRatio DOM property. The value of this property determines the scaling factor used for the current device. For example, if the value of window.devicePixelRatio is "1.0", then the device is considered a device with a dense density, and scaling is not applied by default; if the value is "1.5", then the device is considered a device with a high density, and the default page is scaled 1.5 times; if the value is "0.75", then the device is considered a device with a low density, and the default page scale is 0.75x. Of course, the scaling used by Android Browser and WebView is based on the target density of the web page, as described in the "Determining the density of the target viewing area, the default target is the average density, but you can change the target to affect how your web page scales to different screen densities.
, JavaScript:
if (window.devicePixelRatio == 1.5) {
alert("This is a high-density screen");
} else if (window.devicePixelRatio == 0.75) {
alert("This is a low-density screen");
}
-