【问题标题】:Padding value in androidandroid中的填充值
【发布时间】:2018-03-29 14:47:22
【问题描述】:

这行代码是什么意思?

android 填充 Right = "@ dimen /activity_horizontal_margin".

@dimen 指的是什么?

【问题讨论】:

    标签: android padding


    【解决方案1】:

    您可以像这样使用 dimens 文件,以便您可以轻松地将许多东西设置为相同的值(如代码中的常量),或者您可以轻松地为不同的屏幕尺寸覆盖该值。

    dimen 位于/ res / values / 工作室项目中,如下所示

    dimen.xml
    
    <?xml version="1.0" encoding="utf-8"?>
    
    <resources>
        <dimen name="action_button_min_width">56dp</dimen>
        <dimen name="indeterminate_progress_size">32dp</dimen>
    </resources>
    

    详细了解 android studio 中的项目结构 https://developer.android.com/studio/projects/index.html

    【讨论】:

    • 只是补充一点——你可以像这样使用dimens文件,这样你就可以轻松地将许多东西设置为相同的值(比如代码中的常量),或者你可以轻松地覆盖该值不同的屏幕尺寸。
    【解决方案2】:

    dimen.xml 是您可以为尺寸设置常量值的文件。

    <resources>
       <!-- Default screen margins, per the Android Design guidelines. -->
       <dimen name="activity_horizontal_margin">16dp</dimen>
       <dimen name="activity_vertical_margin">16dp</dimen> 
    </resources>
    

    它通常在 /res/values 文件夹中创建。如果您在那里找不到它,您可以创建和添加值。

    您可以参考以下链接了解更多详情。

    https://developer.android.com/samples/BasicSyncAdapter/res/values/dimen.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      • 2010-11-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多