Android: Default attributes for custom views

后端 未结 3 1004
渐次进展
渐次进展 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:08

    I solved my own problem thusly:

    res/values/attrs.xml:

    
        
    
    

    res/values/styles.xml:

    
        
    
        
    
    

    Then all you do is set the theme in the manifest to AppTheme. This also works with standard widgets using android:[widget]Style in place of customViewStyle in the definition of AppTheme.

提交回复
热议问题