Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何支持针对style.xml里的Theme换肤 #5

Open
aqiansunboy opened this issue Oct 26, 2015 · 4 comments
Open

如何支持针对style.xml里的Theme换肤 #5

aqiansunboy opened this issue Oct 26, 2015 · 4 comments

Comments

@aqiansunboy
Copy link

image

楼主,针对这种主题式换肤,怎么办呀?目前该框架从代码上看好像不支持~

@envyfan
Copy link

envyfan commented Oct 26, 2015

。。我是直接在代码中改变toolbar和statusbar颜色的0 0

@aqiansunboy
Copy link
Author

我能想到的办法也是这样,不过感觉这样不优雅

@aqiansunboy
Copy link
Author

我找到了个办法,在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);
     }
}

@huangjim
Copy link

huangjim commented Dec 4, 2015

加进去了如何使用呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants