burgessjp / themeskinning Goto Github PK
View Code? Open in Web Editor NEWA library can easy to change your app's theme for android
A library can easy to change your app's theme for android
我是按照下面方式创建的,但是没有更换。
ImageView imb = new ImageView(getContext());
imb.setImageDrawable(getResources().getDrawable(R.drawable.pi12));
ViewGroup.MarginLayoutParams paramsimg = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imb.setLayoutParams(paramsimg);
dynamicAddView(imb, "background", R.drawable.pi12);
SkinManager类的getDrawable方法,目前只能从drawable目录下加载。
在自己扩展属性的时候,有可能需要从其他目录(比如anim)下加载drawable,因此希望能够加一个新的方法,可以自己指定目录,就像这样 getDrawable(String defType, int resId)。
怎么改变toolbar的item icon
换图片背景的怎么弄呢?
如果可以的话能否贴一下代码?方便的话可以加一下我的QQ吗?840103844 以便有不懂的地方能问一下
如果动态添加一个Layout,里面有多个View需要进行换肤,这个时候除了手动去一个个添加,还有别的方案吗
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:359)
最新的代码中,在SkinBaseFragment类的onDestroyView()方法里,移除了Fragment相关的View,但是在SkinInflaterFactory类的成员变量mSkinItemMap里只是移除了Fragment本身的View,那些子View并未从mSkinItemMap里移除,那样的话子View还是不能被释放内存。不知道我的理解是否有误,希望作者能解答一下!
我看那个动态添加的方法只能传入view
style如何换肤?直接把主题包放一份名字一样的style无效
比如https://github.com/H07000223/FlycoTabLayout 这种,项目里用到了这个做导航菜单,需要更换导航上的图标。
这类自定义控件换肤怎么实现呢?
当前使用版本:1.4.6
在background中设置selecter,其select中引用的资源名和插件中的资源名完全一致,通过 skin:enable="true" 无法动态更换,
随后我使用dynamicAddView函数也无法更换
Apk第一次安装的时候,在Application中加载其他皮肤的时候,在我的引导页中会闪烁一下原先的皮肤,然后才变成正确的皮肤,这个是加载来不及吗?
我试了无法切换颜色。
public class ImageViewSrcAttr extends SkinAttr {
@Override
protected void applySkin(View view) {
if (view instanceof ImageView) {
ImageView iv = (ImageView) view;
if (isDrawable()) {
iv.setImageDrawable(SkinResourcesUtils.getDrawable(attrValueRefId));
} else if (isColor()) {
iv.setBackgroundColor(SkinResourcesUtils.getColor(attrValueRefId));
}
}
}
}
在ImageViewSrcAttr中这样写的话,如果xml中这样设置:
android:src="@color/main"
实际就没有换肤效果了。是否应该将setBackgroundColor改成
setImageDrawable(new ColorDrawable(SkinResourcesUtils.getColorattrValueRefId)))
我测试了一下,这样就正确换肤了。
如何在服务(service)中换dialog的皮肤呢?
SystemBarTintManager,
mNavBarAvailable = a.getBoolean(1, false);
这里面的1对应的是哪个
widget使用widgetprovider创建,并不能通过activity和fragment进行换肤,请问有遇到过这种情况么,如何处理?
在solid.ren.skinlibrary.loader.TextViewRepository类中由于你用了个静态的mTextViews 产生了严重的内存泄漏
最新的代码中,在SkinBaseFragment类的onDestroyView()方法里,移除了Fragment相关的View,但是在SkinInflaterFactory类的成员变量mSkinItemMap里只是移除了Fragment本身的View,那些子View并未从 mSkinItemMap里移除,那样的话子View还是不能被释放内存。不知道我的理解是否有误,希望作者能解答一下!
谢谢。
我listview的childview设置了主题,当list滑动时候这些主题就变回原来的了
Error:A problem occurred configuring project ':app'.
Could not find support-v4.jar (com.android.support:support-v4:24.0.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/24.0.0/support-v4-24.0.0.jar
还是说 如果想使用换肤 必须在代码中动态设置setImageDrawable()?
如题,能否给出相关文档,是继承SkinAttr这个类吗?
另:主页的文档好像不是最新的,还希望作者更新一下哦
之前切肤时可以的,今天启动APP后,突然间不行了。用的时1.3.1版本
SkinManager manager = SkinManager.getInstance();
怎么不把 context 传进来呀..
有解决办法吗?
@drawable/selector_item
在style内的background为针对drawable资源的引用时,SkinInflaterFactory.parseSkinAttr的TypedArray.getColor()在4.几的机子上会抛出错误,6.0的机子没问题,5.0的没试过
Caused by: android.content.res.Resources$NotFoundException: android.content.res.Resources.loadColorStateList(Resources.java:2088)
android.content.res.TypedArray.getColor(TypedArray.java:326)
solid.ren.skinlibrary.loader.SkinInflaterFactory.parseSkinAttr(SkinInflaterFactory.java:93)
PS:所有引用资源写成@null时,getResourceEntryName()方法也会抛出异常导致崩溃
在int trueResId = mResources.getIdentifier(resName, "drawable", skinPackageName);这句里得到了trueResId,这时候应该先判断trueResId是否为0,等于0的话直接返回originDrawable即可。
如果不判断的话,虽然try catch可以捕获到异常,但是不是很好的写法,可以用判断处理的就不要通过抛异常处理。在应用提交到一些自动化测试平台(比如阿里)的时候,会检测应用抛出异常的次数,目前我在应用里集成这个库,自动化测试平台报出调用这个库发生了100多个异常,这样会认为应用的健壮性差。库里getColor方法也一样有这个问题,所以希望能够改进下。
当MainActivity(应用主界面,一般是和应用的生命周期是一样的)中包含一个ViewPager,ViewPager包含有很多的Fragment,当Fragment已经销毁的时候,然而其中的View还依然保存在SkinInflaterFactory的mSkinItems中,所以一直保存着其引用,不会释放,当Fragement重新创建的时候,又会有新的相同的View重新创建,由于MainActivity和应用的生命周期是一样的,mSkinItems一直不会被销毁,所以当多次滑动ViewPager就很容易发生内存溢出。目前正在寻求比较好的解决方案
使用getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);设置全屏后,状态栏会显示设置的statusbar颜色,给statusbar设置透明也无效
此Issue主要目的是讨论
小弟不才 因为想写一个换icon的demo 发现按步骤配置之后不生效 于是排查了一下问题所在
最终定位在SkinManager类的312行
int trueResId = mResources.getIdentifier(resName, "drawable", skinPackageName);
原因是第二个参数写死为drawable 而我想换的资源文件在mipmap中
所以此时 trueResId必然为0
期望替换的图片也不会被替换
虽说是约定优于配置 但还是感觉对于一些场景不太灵活
比如 有个项目已经做完了 版本迭代时提出要添加换肤功能
而此时项目中大部分图片都放置在mipmap中
如果把mipmap中所有图片搬到drawable 显然工作量不小 而且容易出错
个人建议是 getDrawable() 函数中
if (trueResId == 0) {
trueDrawable = originDrawable;
}
修改成
if(trueResId==0) {
trueResId = mResources.getIdentifier(resName, "mipmap", skinPackageName);
if (trueResId == 0) {
trueDrawable = originDrawable;
}
else{
//do something
}
}
未通读所有原代码 不能保证其正确与合理性
仅供查验与参考 有误望指出
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.