android - What does defStyleAttr and defStyleRes in context.obtainStyledAttributes() used for? -
when check quickcontactbadge
in framelayout
, found following code:
public quickcontactbadge(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); typedarray = context.obtainstyledattributes(attrs, com.android.internal.r.styleable.quickcontactbadge, defstyle, 0); mmode = a.getint(com.android.internal.r.styleable.quickcontactbadge_quickcontactwindowsize, quickcontact.mode_medium); a.recycle(); init(); mbadgebackground = getbackground(); }
i don't catch meaning of defstyle
, 0
parameter in obtainstyledattributes()
. have looked reference, still don't know used for.
the documentation explains pretty clearly, did see part:
defstyleattr attribute in current theme contains reference style resource supplies defaults values styledattributes. can 0 not defaults.
defstyleres resource identifier of style resource supplies default values styledattributes, used if defstyleattr 0 or can not found in theme. can 0 not defaults.
"can 0 not defaults." if set 0 it's not going try grab default values style attributes. seem little counter-intuitive, why overload method if can pass in 0... think can tell not in defstyleattr
defaults do tell in defstyleres
defaults, , vice versa.
Comments
Post a Comment