Skip to content

onlike/Android_Skin_Module

Repository files navigation

Android Skin Module

dynamic android skin module for application

  1. support dynamic add view to skin.
  2. support skin attr extanded to use for most view.
  3. support customize resource parse when you want to do something.
  4. support cold start skin effective.
  5. force prevent fragment create skin view memory leak.

Screenshots

1.How to use?

a : take skin file

1.take skin resource in lib_skin_factory project , such as sample , pay attention resource name must same to target .

2.use gradle command "assembleDebug" or "assembleRelease" in lib_skin_factory project , the skin file will be create in path "/lib_skin_factory/skin_output/".

b : import skin module

at now , skin module just provide libaray mode to import , lool like:

        compile project(':lib_skin')
  

c : init skin module

you must init skin module in your custom application

      SkinManager.init(this);
  

d : load skin

you can load skin file in any where

      SkinManager.getInstance().load();
      // or
      SkinManager.getInstance().load(SkinLoadCallback callback)
      // or
      SkinManager.getInstance().load(final String skinPath, final SkinLoadCallback callback);
  

e : clear skin

clear already load skin file and take default skin effictive

      SkinManager.getInstance().clearSkin();
  

f : about support

1.library support extanded skin attr

      SkinManager.getInstance().addSkinAttrType(String attrName, Class<? extends BaseAttr> cls);
  

2.library support customize resource parse

      SkinManager.getInstance().setResourceParse(IResourceParse parse);
  

#tips

  Do't need call skin load when application already load it at last runtime .


2.Core logic code.

View Prase.(take a customize xml prase create view to find skin enable view)

        LayoutInflaterCompat.setFactory(LayoutInflater inflater, LayoutInflaterFactory factory);
  

Resource Prase.(use reflection init a resource object to load assetmanager)

         AssetManager assetManager = AssetManager.class.newInstance();
         Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
  
         Resources skinResource = new Resources(AssetManager assets, DisplayMetrics metrics, Configuration config);
  

3.TODO

  • a. support maven center to import.
  • b. optimization skin fackory library.
  • c. add project mind map.

About

dynamic android skin module for application

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages