首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >attrs.xml中的安卓常量

attrs.xml中的安卓常量
EN

Stack Overflow用户
提问于 2013-02-12 14:38:26
回答 1查看 1.7K关注 0票数 0

我看到在android attrs.xml (data/res/value/attrs.xml)中声明的维度常量,比如

代码语言:javascript
复制
<attr name="padding" format="dimension" />
<!-- Sets the padding, in pixels, of the left edge; see {@link android.R.attr#padding}. -->
<attr name="paddingLeft" format="dimension" />
<!-- Sets the padding, in pixels, of the top edge; see {@link android.R.attr#padding}. -->
<attr name="paddingTop" format="dimension" />
<!-- Sets the padding, in pixels, of the right edge; see {@link android.R.attr#padding}. -->
<attr name="paddingRight" format="dimension" />

如果我没记错,这个值在./data/res/values/styles.xml中定义为<item name="android:paddingLeft">20dp</item>,依此类推。

这些是某种“首选”维度值吗?这些值在两次发布之间是否相对稳定,因此如果直接使用这些常量,外观不会受到影响。

谢谢。

编辑:

为了澄清一点,我想知道在我的视图布局中使用这些"android“定义的值有什么含义,比如。

代码语言:javascript
复制
<TextView android:text="@string/text"
    android:layout_width="wrap_content"
    android:layout_height="?android:attr/listPreferredItemHeightSmall"
    android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"/>

我没有定义这些值,而是在android名称空间中引用它。这样做安全吗?

EN

回答 1

Stack Overflow用户

发布于 2013-02-12 14:42:25

我不确定我是否正确理解了这个问题,但如果你使用独立的单位,如dp,dip,sp等,而不是以像素为单位的原始值,那么它在不同设备上看起来是一样的。你可以在这里读到它:http://developer.android.com/guide/practices/screens_support.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14826872

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档