Android: Default attributes for custom views

后端 未结 3 999
渐次进展
渐次进展 2021-02-14 20:24

I have a custom view that extends one of the framework classes. Most Views in Android have some default attributes defined for them (such as Button bei

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-14 21:12

    I think you will need to override the View constructors that take an AttributeSet argument, and build your own modified AttributeSet to pass to the superclass constructor.

    EDIT: Even easeer, just have your View subclass constructor call setClickable etc to change the defaults to what you want.

提交回复
热议问题