android 动态换肤框架,GitHub - ss520k/Android-Skin-Loader: 一个通过动态加载本地皮肤包进行换肤的皮肤框架...

Android-Skin-Loader

更新日志

导入到Android Studio,使用gradle构建皮肤包(见7. 皮肤包是什么?如何生成?)(2015-12-02)

解决Fragment换肤在某些版本的support-v4包下失效的问题(感谢@javake同学)(2015-12-02)

对textColor加入selector类型的资源的换肤支持(感谢@pinotao同学) (2015-09-26)

添加在代码中创建的View的换肤支持 (2015-09-24)

工程目录介绍

Android-Skin-Loader

├── android-skin-loader-lib // 皮肤加载库

├── android-skin-loader-sample // 皮肤库应用实例

├── android-skin-loader-skin // 皮肤包生成demo

└── skin-package // 皮肤包输出目录

演示

1. 下载demo, 将BlackFantacy.skin放在SD卡根目录

2. 效果图

换肤前

4090648c20586cd2ff72982d4a79028b.png

换肤后

demo2.gif

用法

1. 在Application中进行初始化

public class SkinApplication extends Application {

public void onCreate() {

super.onCreate();

// Must call init first

SkinManager.getInstance().init(this);

SkinManager.getInstance().load();

}

}

2. 在布局文件中标识需要换肤的View

...

xmlns:skin="http://schemas.android.com/android/skin"

...

...

skin:enable="true"

... />

3. 继承BaseActivity或者BaseFragmentActivity作为BaseActivity进行开发

4. 从.skin文件中设置皮肤

String SKIN_NAME = "BlackFantacy.skin";

String SKIN_DIR = Environment.getExternalStorageDirectory() + File.separator + SKIN_NAME;

File skin = new File(SKIN_DIR);

SkinManager.getInstance().load(skin.getAbsolutePath(),

new ILoaderListener() {

@Override

public void onStart() {

}

@Override

public void onSuccess() {

}

@Override

public void onFailed() {

}

});

5. 重设默认皮肤

SkinManager.getInstance().restoreDefaultTheme();

6. 对代码中创建的View的换肤支持

主要由IDynamicNewView接口实现该功能,在BaseActivity,BaseFragmentActivity和BaseFragment中已经实现该接口.

public interface IDynamicNewView {

void dynamicAddView(View view, List pDAttrs);

}

**用法:**动态创建View后,调用dynamicAddView方法注册该View至皮肤映射表即可(如下).详见sample工程

private void dynamicAddTitleView() {

TextView textView = new TextView(getActivity());

textView.setText("Small Article (动态new的View)");

RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

param.addRule(RelativeLayout.CENTER_IN_PARENT);

textView.setLayoutParams(param);

textView.setTextColor(getActivity().getResources().getColor(R.color.color_title_bar_text));

textView.setTextSize(20);

titleBarLayout.addView(textView);

List mDynamicAttr = new ArrayList();

mDynamicAttr.add(new DynamicAttr(AttrFactory.TEXT_COLOR, R.color.color_title_bar_text));

dynamicAddView(textView, mDynamicAttr);

}

7. 皮肤包是什么?如何生成?

皮肤包(后缀名为.skin)的本质是一个apk文件,该apk文件不包含代码,只包含资源文件

在皮肤包工程中(示例工程为skin/BlackFantacy)添加需要换肤的同名的资源文件,直接编译生成apk文件,再更改后缀名为.skinj即可(防止用户点击安装)

使用gradle的同学,buildandroid-skin-loader-skin工程后即可在skin-package目录下取皮肤包(修改脚本中def skinName = "BlackFantacy.skin"换成自己想要的皮肤名)

License

Copyright [2015] [FENGJUN]

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441263.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【CodeForces - 349A】Cinema Line (贪心(其实不是贪心),乱搞)

题干: The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the boo…

android 获取默认程序图标,android – PackageManager.getApplicationIcon()返回默认图标?...

我刚想通了.有一个PackageManager.getDefaultActivityIcon()方法返回一个Drawable.如果Drawable的Bitmap与应用程序图标Drawable的Bitmap匹配,则它是默认图标.PackageManager pm context.getPackageManager();Drawable icon pm.getApplicationIcon(apk.package_name);Drawabl…

【CodeForces - 255A】Greg's Workout (水题)

题干: Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a1, a2, ..., an. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in orde…

android吸附菜单,Android仿微博、人人Feed详情页吸附导航栏

仿微博、人人的feed详情页面:Listview上下滑动,导航栏view可吸附在顶部的效果。一、实现效果上图:效果图.gif欢迎拍砖,拍拍更进步。没有对比,怎么会有伤害,下面是 微博、人人的Feed详情页:微博、…

android 居右属性,使用layoutDirection属性设置布局靠左或靠右

通过设置layoutDirection属性值为mx.core.LayoutDirection.RTL(右到左)或mx.core.LayoutDirection.LTR(左到右),使布局为靠左或靠右(如下图)。该属性可设置3种值,LayoutDirection.RTL、LayoutDirection.LTR和null(ILayoutDirectionElement时)/undefined(…

【CodeForces - 255B】Code Parsing(思维,字符串)

题干: Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitalys algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime: …

【CodeForces - 255C】Almost Arithmetical Progression (dp,离散化)

题干: Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as: a1  p, wh…

Android手机mm开头的大文件,[2018年最新整理]2Android源代码编译命令m和mm和mmm以及make分析.doc...

[2018年最新整理]2Android源代码编译命令m和mm和mmm以及make分析老罗的新浪微博:/shengyangluo,欢迎关注!在前文中,我们分析了Android编译环境的初始化过程。Android编译环境初始化完成后,我们就可以用m/mm/mmm/make命…

【CodeForces - 349C】Mafia(思维模拟,优秀的二分)

题干: One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a pl…

android新材料设计,android - 如何实现新材料BottomAppBar为BottomNavigationView - SO中文参考 - www.soinside.com...

解决了基本上,而不是试图迫使菜单的资源,我需要的布局,我用这个方法,而不是,我只是把使用“空”元素作为dglozano建议BottomAppBar内的LinearLayout。使用?attr/selectableItemBackgroundBorderless我也能做到这一点实…

【CodeForces - 1A】Theatre Square(水题,几何)(CODEFORCES,梦的开始)

题干: Theatre Square in the capital city of Berland has a rectangular shape with the size n  m meters. On the occasion of the citys anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the …

html教程是语音版,【HTML教程】HTML 语言简介

标签是一个容器标签,用于放置网页的主体内容。浏览器显示的页面内容,都是放置在它的内部。它是的第二个子元素,紧跟在后面。网页标题hello world

【POJ - 1664】放苹果 (递归经典题 或 dp 或 母函数)

题干: 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input 第一行是测试数据…

html文本下一页,Javascript html2canvas + jsPDF 导出PDF,解决一半文字在上一页一半文字在下一页的问题...

var pdfContent document.getElementById("pdfDiv");var width pdfContent.offsetWidth; //获取dom 宽度var height pdfContent.offsetHeight; //获取dom 高度var canvas document.createElement("canvas"); //创建一个canvas节点var scale 3; //定义…

无法设置html过渡效果,html – CSS3过渡显示无阻止过度滚动

我假设你的弹出窗口是绝对定位的,所以你可以做以下事情:>隐藏时,将弹出窗口设置为巨大的负值.这会将其移出屏幕并摆脱滚动条.>在悬停时,将顶部设置为正确的值并转换不透明度值.>确保CSS转换规则仅适用于opacity属性.HTMLPopup go nowMy cats breath smells…

ACM 题目分类POJ(自用,精)

详情见博客:http://exp-blog.com/2018/06/28/pid-38/ 和博客https://blog.csdn.net/a1dark/article/details/11714009/ http://exp-blog.com/2018/06/10/pid-136/ https://blog.csdn.net/lyy289065406/article/details/6642573

html表格全屏显示,tableView滑动全屏显示

今天要分享的一个效果是在一个页面弹出视图展示一个tableview,然后手指滑动tableview时,视图随着tableview偏移量增加而慢慢增加,到达临界时,全屏显示,然后再次向下滑动时,当偏移量到达临界点,视…

【 CodeForces - 864B】Polycarp and Letters(水题,字符串,有坑)

题干: Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string sconsisting only of lowercase and uppercase Latin letters. Let A be a set of positions in the string. Lets call it pretty if following conditions are met:…

计算机网络65535,计算机网络1

1.网络基础:1.1 IT行业铁三角:os,web,sql 不管是哪个IT岗位都应该懂,1.2 开发铁三角:语言,数据结构算法,数据模式1.3 测试铁三角:需求,搭环境和设计用例&…

【CodeForces - 864C】Bus (模拟,有坑)

题干: A bus moves along the coordinate line Ox from the point x  0 to the point x  a. After starting from the point x  0, it reaches the point x  a, immediately turns back and then moves to the point x  0. After returning to the point…