How to get accent color programmatically?

前端 未结 7 2376
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 03:32

How would one fetch the accent color set in styles, like below, programmatically?

    @color/material_green_500<         


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-05 04:16

    This worked for me as well:

    public static int getThemeAccentColor (final Context context) {
        final TypedValue value = new TypedValue ();
        context.getTheme ().resolveAttribute (R.attr.colorAccent, value, true);
        return value.data;
    }
    

提交回复
热议问题