Theme style for custom view

后端 未结 1 417
执笔经年
执笔经年 2020-12-21 03:35

My app has several themes from which the user can chose (red, blue, green etc.) Every theme has a corresponding button style (RedTheme => RedButton). Now I have created a cu

相关标签:
1条回答
  • 2020-12-21 04:16

    I'm using the three parameter super constructor and pass the button style resource id. This works for all my custom themes. Thanks @pskink for pointing me into right direction.

    public ClockButton(Context context, AttributeSet attrs) {
        super(context, attrs, R.attr.buttonStyle);
        ...
    }
    

    My theme looks like this:

    <style name="LilaTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="buttonStyle">@style/ButtonmyTimeLila</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题