Tutorial: How Android Apps can make skin changes

Source: Internet
Author: User

Objective of this course: to learn how to change the skin and realize the advantages and disadvantages of different skin changing options and the applicable occasions.

Hope that all students do: learn a skill to master the thorough, more practice. It is best to extrapolate and comprehend by analogy, and to master the thinking and method of analyzing problem solving problem.

I am explaining the principles and key technical points of implementation that may not be explained in detail, optimization, or content that is not relevant or elementary to the subject matter of the course. This is free training, limited energy, temporarily can only do to make the ordinary become excellent, so that excellent change of excellence. If you've been brilliant, teach me. Do not start training for the time being.

There are many domestic software support skin customization, which is also a major difference with foreign software, foreign users pay attention to social, mail and other functions, domestic users pay attention to music, novels, Skins and other functions, this section of the course to explain how Android application to achieve skin changing function.

http://dict.baidu.com/s?wd=%E3%80%90%E5%88%98%E5%BF%83%E8%AF%ADQQ%3A2911834916+100%25%E4%B8%B0%E8%83%B8%E6%88% 90%e5%8a%9f+%e6%b8%85%e6%9c%9d%e5%ae%ab%e5%bb%b7%e4%b8%b0%e8%83%b8%e8%8c%b6%e3%80%91%e4%b8%80%e4%b8%aa%e6%9c% 88%e5%a2%9e%e5%8a%a0%e4%b8%80%e4%b8%aa%e7%bd%a9%e6%9d%af

The software peels can be divided into three kinds of functions:

1) The software contains multiple skins, which cannot be added or modified by the user;

The lowest degree of freedom, the software implementation is the most easily compared to the latter two.

2) The official supply of skin for download, users can use the downloaded skin;

Users can choose to download their favorite skin, some players will crack the skin of custom methods, do their own skin use, or upload to the internet for everyone.

3) The official skin production tools or methods, the user can self-made skin.

http://dict.baidu.com/s?wd=%E3%80%90%E5%88%98%E5%BF%83%E8%AF%AD%E4%B8%B0%E8%83%B8%E8%8C%B6QQ%3A2911834916+100% 25%e4%b8%b0%e8%83%b8%e6%88%90%e5%8a%9f+%e4%b8%80%e4%b8%aa%e6%9c%88%e5%a2%9e%e5%8a%a0%e4%b8%80%e4%b8%aa%e7%bd% a9%e6%9d%af%e3%80%91

This approach gives users a sense of participation and a higher degree of freedom. Users can customize the skin of the software according to their preferences. Some software websites provide skin-specific tools or methods, and I recommend that you have a visual guide tool. Users only need to find some of their own pictures, modify the font of the text to replace it. Users can upload homemade skins, provide other users with the ability to download, and earn some virtual money or prizes. This is typically packaged in. zip format. Extensions can be customized by each company, and it is most convenient to export them directly with production tools.

First we need to clarify the definition of skin, software skins including icons, fonts, layouts, interactive style, etc., skin replacement is to replace some or all of the resources.

The three skin types mentioned above, from the software implementation point of view, their essential difference is whether the skin is built into the application. For the built-in implementation is relatively simple, as long as the development of applications in the process of designing several sets of skin for users to choose. The knowledge used here does not exceed the Android base and is not explained in detail.

This lesson focuses on how to isolate the skin from the application.

The skin generally contains a number of files, such as samples, configuration and other files, scattered files are not conducive to transmission and use, preferably packaged. The packaged format generally selects the ZIP format. Here are two cases, one is the apk, such as Adwlauncher, its desktop skin format is an apk, the other is a custom extension, such as ink weather skin extension is mja, Sogou input Method's skin extension is SGA, their file format is actually zip.

Here we explain separately.

A APK format

Now the question becomes how an app can read the resources in another apk.

In the Android system, the APK can read data between each other condition is: the same signature, and the Androidmanifest.xml file is configured in the same Android:shareduserid attribute value, then two apk run in the same process, can access any data from each other.

Here's how:

1) configuration of application and skin program in Androidmanifest.xml

Example: android:shareduserid= "Org.yuchen"

2) file and app match the skin file name of the same feature in APK

Example: The application's background picture path:/skindemo/res/drawable-hdpi/bg.png

Then the background image file path in the skin apk should also be:

Customskin/res/drawable-hdpi/bg.png

3) Ways to access resources

[Java] View plaincopyprint?

Context context = Createpackagecontext ("Com.yuchen.customskin", context.context_ignore_security);

Gets the context that corresponds to the Org.yuchen.customskin, and can access any resource in the Org.yuchen.customskin by returning the context object.

For example: App apk to get bg.png in the skin apk,

[Java] View plaincopyprint?

drawable drawable = Context.getresources (). getdrawable (r.drawable.bg);

This gives a reference to the image, and other XML resource files are obtained in a similar manner.

Two Custom extensions for zip-format skins

The technical point is how to read the resources in the zip file and the skin file storage policy.

Scenario: If the software starts each time to read the skin files on the SD card, the speed will be slower. A good practice is to provide a skin settings interface, the user chose which skin, the skin file extracted to the "/data/data/[package Name]/skin" path, so that does not need to read across the memory, faster, And do not need to go to the zip archive every time to read, do not rely on the SD card files, even if the skin compression package files are deleted is not related.

Implementation method:

1. Prompt the user to copy the skin files to the SD card under the specified path in the help of the software or the official website.

2. Provide the skin setting interface in the software. Can be in the menu or in the settings. can refer to ink, Sogou input method, QQ and other support for skin-changing software.

3. Load the skin file under the specified path, read the thumbnail, and display it in the skin Settings screen to extract the user-selected skin files to the "/data/data/[package Name]/skin" path.

4. In the software, read the resources in the "/data/data/[package name]/skin/" path first. If not, use the resources in the APK.

Tutorial: How Android Apps can make skin changes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.