我看到在android attrs.xml (data/res/value/attrs.xml)中声明的维度常量,比如
<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“定义的值有什么含义,比如。
<TextView android:text="@string/text"
android:layout_width="wrap_content"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:paddingStart="?android:attr/expandableListPreferredItemPaddingLeft"/>我没有定义这些值,而是在android名称空间中引用它。这样做安全吗?
发布于 2013-02-12 14:42:25
我不确定我是否正确理解了这个问题,但如果你使用独立的单位,如dp,dip,sp等,而不是以像素为单位的原始值,那么它在不同设备上看起来是一样的。你可以在这里读到它:http://developer.android.com/guide/practices/screens_support.html
https://stackoverflow.com/questions/14826872
复制相似问题