Can't get splash screen icon on Android Chrome PWA

前端 未结 1 1506
遇见更好的自我
遇见更好的自我 2020-12-22 02:17

I\'ve created a PWA that installs correctly, with a launcher icon. I want a different image for the splash screen, so I\'ve included 192px and 512px png\'s, both 128dpi and

相关标签:
1条回答
  • 2020-12-22 02:41

    According to this documentation, as you have already known, Chrome will choose the icon that closely matches the 128dp icon for that device.

    Please take note that dp (Density-independent Pixels) is different from dpi (Dots Per Inch). Simply put, 128dpi is not necessarily equal to 128dp, which is most likely the problem in your case.

    This SO answer explains the difference between the two well.

    For example, on a 160dpi screen, 1dp == 1px == 1/160in, but on a 240dpi screen, 1dp == 1.5px. So no, 1dp != 1px. There is exactly one case when 1dp == 1px, and that's on a 160dpi screen. Physical measurement units like inches should never be part of your design—that is, unless you're making a ruler.

    A simple formula for determining how many pixels 1dp works out to is px = dp * (dpi / 160).

    Based on this simple formula, your 192px, 128dpi image has 240dp, while your 512px, 128dpi image has 640dp. Assuming your other images all have 128dpi as well, then Chrome is most likely picking your 96px image due to it having the closest dp to 128dp.

    In conclusion, for your 192px or 512px images to have 128dp, they need to have 160dpi.

    0 讨论(0)
提交回复
热议问题