标签:
<?xml version="1.0" encoding="UTF-8"?> <resources> <!-- attrs属性文件 --> <!--declare-styleable里标示的属性可以利用其父属性里的“内容(attr标签里的属性)”满足继承, 不可利用其他declare·····里的私有内容(attr),如果需要调用其他declare······里的私有属性,需 添加引用"(如LinearLayout调用ListView里name="divider"的属性)":源码?: //表示控件为Listview (1) <declare-styleable name="ListView"> <attr name="divider" format="reference|color" /> </declare-styleable> //LinearLayout布局控件 <declare-styleable name="LinearLayout"> <attr name="divider" />//此为引用(1)控件即ListView控件的私用属性 </declare-styleable> 以上两个组件都有共同的最终父类View,所以可以直接利用View里标示的属性“(如他们都可以在xml里用 padding、background、margin、marginLeft等属性)”,如需引用其他declare-styleable 内的属性,需在内部添加注明引用,如上所述,其他declare-styleable里的私有属性都可引用,不过需要内部 注明。 --> <!-- themes文件和styles文件对attrs中属性的引用,没搞清楚,貌似attrs文件里的属性值 都可引用,但style时定义控件风格的,theme时定义整个application或activity样式的,作用范围 不一样 --> <!-- ?以下引用方式通过attr属性 <item name="dropdownListPreferredItemHeight"> ?android:attr/listPreferredItemHeightSmall</item> 直接引用属性值,如果定义多个此属性值,只能友情提示,不能多次第一一个属性值,唯一性,对于一个会报错的,如果你在 你自定义的风格里设置的话应该会优先调用你自己设置的。 -----------------------属性唯一性--------------------- 这个问号引用应该是根据attrs文件下的android:attr/listPreferredItemHeightSmall来遍历所有的有这个 “属性(listPreferredItemHeightSmall)”的设置,然后就引用这个设置,如果关于这个属性的设置,超过一个, android内部应该就判断不了,就报错提示。 这种一个属性有两个<item name="listPreferredItemHeightSmall">@·····</item>的话,如果直接在另一 个<item name="dropdownListPreferredItemHeight"> ?android:attr/listPreferredItemHeightSmall</item> 属性下引用这个属性的话,应该会报错,唯一性,不报错应该有优先权问题出现,前提是都是?android:attr引用这个下的, ?attr/····名字和以上相同没事,不同文件下。 --> <!-- themes.xml(sdk内部)源码 --> <declare-styleable name="WindowAnimation"> <!-- The animation used when a window is being added. --> <attr name="windowEnterAnimation" format="reference" /> <!-- The animation used when a window is being removed. --> <attr name="windowExitAnimation" format="reference" /> <!-- The animation used when a window is going from INVISIBLE to VISIBLE. --> <attr name="windowShowAnimation" format="reference" /> <!-- The animation used when a window is going from VISIBLE to INVISIBLE. --> <attr name="windowHideAnimation" format="reference" /> </declare-styleable> <!-- ListView控件的属性 --> <declare-styleable name="ListView">//表示组件为Listview <!-- Reference to an array resource that will populate the ListView. For static content, this is simpler than populating the ListView programmatically. --> <attr name="entries" />//Listview的引用属性 <!-- Drawable or color to draw between list items. --> <attr name="divider" format="reference|color" />//Listview的私有属性 <!-- Height of the divider. Will use the intrinsic height of the divider if this is not specified. --> <attr name="dividerHeight" format="dimension" /> <!-- 此处省略 --> </declare-styleable> <!-- 以下列举了View的一部分属性 --> <declare-styleable name="View"> <attr name="visibility"> <!-- Visible on screen; the default value. --> <enum name="visible" value="0" /> <!-- Not displayed, but taken into account during layout (space is left for it). --> <enum name="invisible" value="1" /> <!-- Completely hidden, as if the view had not been added. --> <enum name="gone" value="2" /> </attr> <!-- 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" /> <!-- Sets the padding, in pixels, of the bottom edge; see {@link android.R.attr#padding}. --> <attr name="paddingBottom" format="dimension" /> </declare-styleable> <!-- Standard orientation constant. --> <!-- Theme的一部分属性 --> <declare-styleable name="Theme"> <attr name="orientation"> <!-- Defines an horizontal widget. --> <enum name="horizontal" value="0" />//orientation的元素(值) <!-- Defines a vertical widget. --> <enum name="vertical" value="1" /> </attr> </declare-styleable> <!-- 以下为LinearLayout的一部分属性 --> <declare-styleable name="LinearLayout"> <!-- Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column. The default is horizontal. --> <attr name="orientation" /><!-- 引用<declare-styleable name="Theme">的属性 --> <attr name="gravity" /> <attr name="divider" />//对listview私有属性的引用 <!-- Defines the maximum weight sum. If unspecified, the sum is computed by adding the layout_weight of all of the children. This can be used for instance to give a single child 50% of the total available space by giving it a layout_weight of 0.5 and setting the weightSum to 1.0. --> <attr name="weightSum" format="float" /> <!-- When set to true, all children with a weight will be considered having the minimum size of the largest child. If false, all children are measured normally. --> <attr name="measureWithLargestChild" format="boolean" /> <!-- 此处省略 --> </declare-styleable> <eat-comment /> <attr name="orientation"> <!-- Defines an horizontal widget. --> <enum name="horizontal" value="0" /> <!-- Defines a vertical widget. --> <enum name="vertical" value="1" /> </attr> <eat-comment /> <attr name="gravity"> <!-- Push object to the top of its container, not changing its size. --> <flag name="top" value="0x30" />//gravity的可选值 <!-- Push object to the bottom of its container, not changing its size. --> <flag name="bottom" value="0x50" /> <!-- Push object to the left of its container, not changing its size. --> <flag name="left" value="0x03" /> <!-- Push object to the right of its container, not changing its size. --> <flag name="right" value="0x05" /> <!-- Place object in the vertical center of its container, not changing its size. --> <!-- 此处省略 --> <!-- Push object to the beginning of its container, not changing its size. --> <flag name="start" value="0x00800003" /> <!-- Push object to the end of its container, not changing its size. --> <flag name="end" value="0x00800005" /> </attr> </resources>
标签:
原文地址:http://www.cnblogs.com/ayue-1994-com/p/4942245.html