1. Introduction
Using a custom theme or skin, you can put the relevant configuration (color, size, etc.) in a new apk compression file, the directory structure is consistent, the APK file is placed in any directory can be accessed, similar to/system/framework/ framework-res.apk, the theme files can be dynamically loaded according to the needs of the software. This is the only way to achieve this, and other ways of interest can be studied by themselves.
The main instantiation of the Assetmanager object and the resources object to implement the
Assetmanager Assetmanager = AssetManager.class.newInstance (); Method Addassetpath = Assetmanager.getclass (). GetMethod ("Addassetpath", String.class); Addassetpath.invoke ( Assetmanager, Skinpkgpath); Resources superres = Context.getresources (); Resources Skinresource = new resources (Assetmanager,superres.getdisplaymetrics (), superres.getconfiguration ());
2. Flowchart
3. Notes
There is a good open source project on GitHub Https://github.com/fengjundev/Android-Skin-Loader, interested friends can study the source code
Copyright NOTICE: This article is a sub-ink original article, not allowed to reprint without Bo master.
Android_ How to switch themes or skins