Storing dimensions in xml file in Android

后端 未结 2 1950
温柔的废话
温柔的废话 2020-12-06 00:38

I am trying to consistently use the same dimension in all the views in my android app (e.g., a left margin of 20dp). If I were using HTML, I would simply use a CSS file, but

2条回答
  •  旧时难觅i
    2020-12-06 00:45

    Create a file called res/values/dimens.xml

    
    
        55dip
        55dip
        170dip
        155dip
    
    

    Then reference them in your other xml:

    android:padding="@dimen/icon_width">
    

提交回复
热议问题