Android defstyle parameter

后端 未结 3 2015
别那么骄傲
别那么骄傲 2021-02-18 19:50

All the classes in Android that can be built using XML have constructors of the form:

Context context, AttributeSet attrs, int defStyle

What is

相关标签:
3条回答
  • 2021-02-18 20:15

    This seems to be broken for custom views which programmatically supply their default style through the constructor, see the google code issue.

    0 讨论(0)
  • 2021-02-18 20:26

    All Views supply this constructor, so every subclass can use its own base style when inflating.

    For the param, I'd like to quote the docs for the View-Class:

    defStyle The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource.

    0 讨论(0)
  • 2021-02-18 20:26

    Quote from alanv, project member, "The documentation is incorrect. The third constructor must be an attribute, e.g. R.attr.*"

    0 讨论(0)
提交回复
热议问题