R.style / styleable / attr

styleable表示属性

public ListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.ListView, defStyle, 0); //styleable表示属性

        CharSequence[] entries = a.getTextArray(
                com.android.internal.R.styleable.ListView_entries); //引用其中的属性

...}

//styleable映射在attrs.xml或者style里面

 主要是看xml中对应的标签

attrs.xml 

<declare-styleable name="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" />
        <!-- Drawable or color to draw between list items. -->
        <attr name="divider" format="reference|color" />
        <!-- Height of the divider. Will use the intrinsic height of the divider if this
             is not specified. -->
        <attr name="dividerHeight" format="dimension" />

 

 attr/style表示主题

 protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, com.android.internal.R.style.Theme_Dialog_Alert);
     }

 

 public CheckBox(Context context, AttributeSet attrs) {
        this(context, attrs, com.android.internal.R.attr.checkboxStyle);
    }

 

(都在themes.xml中)

Theme_Dialog_Alert: 对应主题Theme.Dialog.Alert  <style name="Theme.Dialog.Alert">

checkboxStyle : 默认主题Theme中 <item name="checkboxStyle">

总结:主要还是看xml中的标签

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值