UI for different screen densities

前端 未结 2 535
夕颜
夕颜 2021-01-29 04:00

I don\'t understand the benefit of resources configuration qualifiers designed to support multiple screen densities, for example :

  • for an mdpi you put an icon o

相关标签:
2条回答
  • 2021-01-29 04:08

    You are certainly welcome to just ship -xhdpi drawables and have Android downsample as needed. I expect that many developers do just that.

    However, please understand that you are no longer in control over what your drawables look like on lower densities. You are placing your trust in Android's drawable resampling algorithm, which:

    • is going to be more optimized for low CPU and memory use than would a desktop OS graphics tool, and therefore may not be as good of quality; and

    • may vary by Android OS version

    Shipping alternative artwork in different densities gives you more control, albeit for greater development effort and a larger APK size.

    If you do not want that control, that is your choice. At the same time, please do not begrudge other developers' desire to have that control and have potentially higher quality results on lower-density devices.

    0 讨论(0)
  • 2021-01-29 04:13

    The main reason for that is basically letting you define multiple layouts for each screen size with the possibility to change the "SAME" graphics from a screen size to another, let me give you an example: Imagine that you have an activity which its layout is defined for mdpi and hdpi screens. In the hdpi screen you show a full banner with text inside (let's assume the resource is for this banner is R.drawable.topbanner), however this banner is not comfortable to show in smaller screen like mdpi after resizing, so you decided to make a timmed version of this banner for the mdpi screens with the same resource id (R.drawable.topbanner) in which you removed some text for example. Now the system will decide, depending on the screen size, which one to use.

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