ChangeSkin
ChangeSkin copied to clipboard
如何支持针对style.xml里的Theme换肤

楼主,针对这种主题式换肤,怎么办呀?目前该框架从代码上看好像不支持~
。。我是直接在代码中改变toolbar和statusbar颜色的0 0
我能想到的办法也是这样,不过感觉这样不优雅
我找到了个办法,在SkinAttrSupport类中增加如下一个分支判断,获取主题中的颜色值
else if (attrValue.startsWith("?"))
{
int id = Integer.parseInt(attrValue.substring(1));
TypedValue typedValue = new TypedValue();
TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[]{id});
String entryName = context.getResources() .getResourceEntryName(a.getResourceId(0, 0));
a.recycle();
Timber.d("%s's entryName=@%s", attrName, entryName);
if (entryName != null && entryName.startsWith(SkinConfig.ATTR_PREFIX))
{
skinAttr = new SkinAttr(attrType, entryName);
skinAttrs.add(skinAttr);
}
}
加进去了如何使用呢