首页 > 代码库 > Android自定义属性
Android自定义属性
找到 “D:\eclispe_android\eclipse_en_32_4.4\sdk\platforms\android-22\data\res\values” Android SDK自带的属性文件,截取一段Android的自定义属性:
<declare-styleable name="TextView"> <!-- Determines the minimum type that getText() will return. The default is "normal". Note that EditText and LogTextBox always return Editable, even if you specify something less powerful here. --> <attr name="bufferType"> <!-- Can return any CharSequence, possibly a Spanned one if the source text was Spanned. --> <enum name="normal" value="http://www.mamicode.com/0" /> <!-- Can only return Spannable. --> <enum name="spannable" value="http://www.mamicode.com/1" /> <!-- Can only return Spannable and Editable. --> <enum name="editable" value="http://www.mamicode.com/2" /> </attr> <!-- Text to display. --> <attr name="text" format="string" localization="suggested" /> <!-- Hint text to display when the text is empty. --> <attr name="hint" format="string" /> <!-- Text color. --> <attr name="textColor" /> <!-- Color of the text selection highlight. --> <attr name="textColorHighlight" /> <!-- Color of the hint text. --> <attr name="textColorHint" /> <!-- Base text color, typeface, size, and style. --> <attr name="textAppearance" /> <!-- Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp). --> <attr name="textSize" /> <!-- Sets the horizontal scaling factor for the text. --> <attr name="textScaleX" format="float" /> <!-- Typeface (normal, sans, serif, monospace) for the text. --> <attr name="typeface" /> <!-- Style (bold, italic, bolditalic) for the text. --> <attr name="textStyle" /> <!-- Font family (named by string) for the text. --> <attr name="fontFamily" /> <!-- Text color for links. --> <attr name="textColorLink" /> <!-- Makes the cursor visible (the default) or invisible. --> <attr name="cursorVisible" format="boolean" />
其他的还有比如:
<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" /> <attr name="gravity" /> <!-- When set to false, prevents the layout from aligning its children‘s baselines. This attribute is particularly useful when the children use different values for gravity. The default value is true. --> <attr name="baselineAligned" format="boolean" /> <!-- When a linear layout is part of another layout that is baseline aligned, it can specify which of its children to baseline align to (that is, which child TextView).--> <attr name="baselineAlignedChildIndex" format="integer" min="0"/> <!-- 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" /> <!-- Drawable to use as a vertical divider between buttons. --> <attr name="divider" /> <!-- Setting for which dividers to show. --> <attr name="showDividers"> <flag name="none" value="http://www.mamicode.com/0" /> <flag name="beginning" value="http://www.mamicode.com/1" /> <flag name="middle" value="http://www.mamicode.com/2" /> <flag name="end" value="http://www.mamicode.com/4" /> </attr> <!-- Size of padding on either end of a divider. --> <attr name="dividerPadding" format="dimension" /> </declare-styleable>
Android自定义属性
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。