How to support all the different resolutions of android products

前端 未结 5 1626
我在风中等你
我在风中等你 2020-12-03 02:20

All the different resolutions of the different Android products are driving me nuts.

My first android app that I wrote was designed so it supported the three commonl

5条回答
  •  时光说笑
    2020-12-03 02:39

    You don't have to do that to support different densities. What you do is create different resources folders:

    res/values-ldpi/dimens.xml
    res/values-mdpi/dimens.xml
    res/values-hdpi/dimens.xml
    

    Then Android will decide which file to use. You can have something like:

    
    25dip
    

    and..

    
    20dip
    

    etc. And you shouldn't care about resolution... there are a lot of different resolutions sizes so it would be a hell to take decisions based on that.

    Also, if you use dp instead of pixels, you hardly ever will have to create different dimensions files for each density. Of course, sometimes you have to, but it depends on the app.

提交回复
热议问题