Implementation method of replacing skin for Android Application

Implementation idea of replacing skin function in Android Application

We can make the skin package into an APK file and read the data in the skin package in the application APK.

Conditions for reading data of skin package APK with apk

1. Have the same signature

2. AndroidManifest. Android: shareduserid configured in XML has the same attribute value

If the above conditions are met, the two apks can access data from each other.

Implementation steps of skin replacement function of Android Application

1. Android manifest for applications and skins Configuration in XML

XML / HTML code

android:sharedUserId="com.yee"

2. The application APK and skin APK should have the same skin file name for the same function

For example, the image path to apply APK: \ res \ drawable hdpi \ XX png

The image file path in the skin APK should also be: \ res \ drawable hdpi \ XX png

3. Get skin resources

Java code:

Context context = createPackageContext("com.yee.skin",Context.CONTEXT_IGNORE_Security);

Get skin package com yee. The context corresponding to skin can access the skin APK package com through the returned context object yee. Any resources in skin.

In the application APK, you need to obtain the buttonbackground in the skin APK The PNG code is as follows

Java code:

Drawable drawable = context. getResources(). getDrawable(R.drawable.buttonbackground);

The above is the implementation method of replacing skin for Android application. Continue to sort out relevant materials in the future. Thank you for your support for this site.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>