ouchangxin / dynamicskindemo Goto Github PK
View Code? Open in Web Editor NEWAndroid动态切换皮肤demo
Android动态切换皮肤demo
1.可以切换textview和button的颜色、背景,view的background
2.不支持切换style,例如以下这种
<Button style="@style/textViewNormal" android:id="@+id/btn_blue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginEnd="8dp" android:layout_alignParentEnd="true" android:text="闷*蓝"/>
3.查看了解析的代码,位于SkinItem下的 apply方法,遍历属性,然后对应的view重新设置,我修改了下,但是依然不行,代码如下,请高人指点
public void apply() { if (view == null || attrs == null) return; for (SkinAttr attr : attrs) { String attrName = attr.getAttrName(); String attrType = attr.getAttrType(); String resName = attr.getResName(); int resId = attr.getResId(); if ("background".equals(attrName)) { if ("color".equals(attrType)) { view.setBackgroundColor(SkinManager.getInstance().getColor(resName, resId)); } else if ("drawable".equals(attrType)) { view.setBackground(SkinManager.getInstance().getDrawable(resName, resId)); } } else if ("textColor".equals(attrName)) { if (view instanceof TextView && "color".equals(attrType)) { ((TextView) view).setTextColor(SkinManager.getInstance().getColor(resName, resId)); } } else if ("style".equals(attrName)) { if (view instanceof TextView && "style".equals(attrType)) { ((TextView) view).setTextAppearance(view.getContext(), resId); } else if (view instanceof Button && "style".equals(attrType)) { ((Button) view).setTextAppearance(view.getContext(), resId); } } } }
4.同时不支持,字体大小的设置
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.