ximsfei / Android-skin-support

Android-skin-support is an easy dynamic skin framework to use for Android, Only one line of code to integrate it. Android 换肤框架, 极低的学习成本, 极好的用户体验. "一行"代码就可以实现换肤, 你值得拥有!!!
MIT License
6.42k stars 1.08k forks source link

如何代码获取对应的颜色,SkinCompatResources.getInstance().getColor(R.color.status_bar_color),空指针!!! #432

Closed will12190 closed 3 years ago

will12190 commented 3 years ago

如何代码获取对应的颜色,SkinCompatResources.getInstance().getColor(R.color.status_bar_color),空指针!!!,有时候我需要在代码中动态获取颜色进行设置,赐教,本来想加群的,QQ加入一直提示NaN,在线等

will12190 commented 3 years ago

自己研究了下代码,解决了;分享给新来的朋友; TypedValue typedValue = new TypedValue(); SkinCompatResources.getValue(this, R.color.colorPrimary, typedValue, true); int resourceId = typedValue.resourceId; setColor(resourceId); 就可以啦;我是在使用ImmersionBar 沉浸式式遇到的这个问题

AlohaQwQ commented 3 years ago

有用,感谢老兄