Android skin replacement (2), android skin replacement
The last chapter I wrote two days ago has received a good response on the skin replacement function. Today I will introduce you to another method. Today's implementation strategy was also suggested by netizens. Then I wrote a demo myself to evaluate the advantages and disadvantages of the first method.
This section briefly introduces some unfriendly aspects of the first method for skin replacement. For example, if you click the skin replacement function key, you need to download a resource apk and then reference the resource ID, it is indeed inconvenient for users to use. The method we introduced today is to overcome this drawback, which enables direct switching within the application and storing resource files in the local apk, making it easier to read and operate, the following describes an implementation logic.
There are several features to achieve skin replacement: one is to replace image resources, and the other is to change the text color, size, and content. The implementation policy is implemented based on the asserts directory. If there are two sets of skins that can be changed, we need to create two directories corresponding to the two skins under the asserts folder, they have resources with the same name (including image resources and properties files ). If the first skin is used, all resources in the first directory are called. If the second skin is called, resources in the other directory are used. Because the resources referenced in asserts do not need to be the same as res resources, but can be implemented by calling the corresponding resource path through AssertManager, it is a little less troublesome to implement the R file. Changes in text color and other attributes are stored in properties. You only need to call the attribute values in Properties, which is very simple and convenient. The following is a simple example.
I. References to image resources
Generally, image loading is implemented in two ways: Bitmap and Drawable. The implementation method is also available here.
Ii. Loading TextView property values
Before loading the TextView property value, remember to initialize Properties first. All the property values are in properties.
Iii. Use
Click the button to switch the skin content.
Today's article is short. If you have good ideas or other skin-changing implementations, please trust me and I will continue to introduce it to you in the next few days.
Source Code address: https://github.com/JackCho/SkinChangeDemo2
If it is helpful to you, you are welcome to subscribe to my public account --Android sharing (ID: android_share). The QR code below provides you with timely and high quality Android dry goods.
How can the android program achieve skin replacement?
The software skin change function can be divided into three types:
1) The software has multiple built-in skins and cannot be added or modified by users;
With the lowest degree of freedom, software implementation is easier than the last two.
2) The official website provides skin for download. Users can use the downloaded skin;
Users can choose to download their favorite skins. Some players will crack the custom method of skin, use the skin by themselves, or upload it to the Internet for everyone to use.
3) The official website provides skin preparation tools or methods for users to make skin.
You are talking about 2nd types. I am also studying and haven't figured out
This blog will give a rough explanation and hope to help you. Blog.csdn.net/suiyc/article/details/6329212
How to Implement android skin replacement
Fl the PLUS9 ROM on GFAN
Or I forgot the name of a software from suo aix10.
Or go to ADW or launcher pro.