How to define dimens.xml for every different screen size in android?

后端 未结 9 1809
轮回少年
轮回少年 2020-11-22 00:43

When supporting different screen sizes (densities) in Android often the focus is on creating different layouts for every possible screen. I.E.

9条回答
  •  广开言路
    2020-11-22 01:16

    Android 3.2 introduces a new approach to screen sizes,the numbers describing the screen size are all in “dp” units.Mostly we can use

    smallest width dp: the smallest width available for application layout in “dp” units; this is the smallest width dp that you will ever encounter in any rotation of the display.

    To create one right click on res >>> new >>> Android resource directory

    From Available qualifiers window move Smallest Screen Width to Chosen qualifiers

    In Screen width window just write the "dp" value starting from you would like Android Studio to use that dimens.

    Than change to Project view,right click on your new created resource directory

    new >>> Values resource file enter a new file name dimens.xml and you are done.

提交回复
热议问题