GithubHelp home page GithubHelp logo

xunianddup / android-skin-support Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ximsfei/android-skin-support

0.0 2.0 0.0 41.66 MB

Android-skin-support is an easy to use dynamic skin framework for Android, Only one line of code to integrate it.一款用心去做的Android 换肤框架, 极低的学习成本, 极好的用户体验. 一行代码就可以实现换肤, 你值得拥有!!!

License: MIT License

Java 100.00%

android-skin-support's Introduction

Android-skin-support

In English | 中文

skin-support-v2.1.9 design-v1.2.5 cardview-v1.2.0 v1.0.2

circleimageview-v2.2.0.2 v2.1.2 v1.4.5

Android-skin-support is an easy to use skin framework for Android. The best case, Only one line of code to integrate the framework.

SkinCompatManager.withoutActivity(this).loadSkin();

Now, you have a strong skinning feature. What you need to do is make a skin.

default app-in plug-in

Table of Contents

Gradle Dependencies

The Gradle Dependency is available via jCenter,

Add dependencies directly, For the latest version, please refer to change log

compile 'skin.support:skin-support:2.1.9'          // skin-support basic widget
compile 'skin.support:skin-support-design:1.2.5'   // skin-support-design material design support [selectable]
compile 'skin.support:skin-support-cardview:1.2.0' // skin-support-cardview CardView support [selectable]
compile 'skin.support:skin-support-constraint-layout:1.0.2' // skin-support-constraint-layout ConstraintLayout support [selectable]

Integration

Initialization

Only one line of code to integrate the framework.

@Override
public void onCreate() {
    super.onCreate();
    SkinCompatManager.withoutActivity(this)                         // Basic Widget support
            .addStrategy(new CustomSDCardLoader())                  // Custom loader strategy            [selectable]
            .addHookInflater(new SkinHookAutoLayoutViewInflater())  // hongyangAndroid/AndroidAutoLayout [selectable]
            .addInflater(new SkinMaterialViewInflater())            // material design support           [selectable]
            .addInflater(new SkinConstraintViewInflater())          // ConstraintLayout support          [selectable]
            .addInflater(new SkinCardViewInflater())                // CardView v7 support               [selectable]
            .addInflater(new SkinCircleImageViewInflater())         // hdodenhof/CircleImageView         [selectable]
            .addInflater(new SkinFlycoTabLayoutInflater())          // H07000223/FlycoTabLayout          [selectable]
            .setSkinStatusBarColorEnable(false)                     // Disable statusBarColor skin support,default true   [selectable]
            .setSkinWindowBackgroundEnable(false)                   // Disable windowBackground skin support,default true [selectable]
            .loadSkin();
}

Load Skin

// Load the specified skin
SkinCompatManager.getInstance().loadSkin("new.skin"[, SkinLoaderListener], int strategy);

// restore default skin
SkinCompatManager.getInstance().restoreDefaultTheme();

Custom View skin support

  1. Implement the SkinCompatSupportable interface

  2. Apply skin resource in the applySkin method

  3. Resolve the skin resource id in the constructor

Make a skin

BuildIn Skin:

BuildIn Skin,if the skin name is night; Add a resource that needs to be skinned with a suffix _night or prefix night_.

if the default resource is R.color.windowBackgroundColor, then you can add a resource R.color.windowBackgroundColor_night

load buildIn skin:

SkinCompatManager.getInstance().loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN); // load by suffix
SkinCompatManager.getInstance().loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN); // load by prefix

Plug-in Skin:

New Android Application Project

Put the skin resources into the res directory

If the original window background is

colors.xml

<color name="background">#ffffff</color>

for night-mode you can add this in the skin-night project

colors.xml

<color name="background">#000000</color>

Generated apk is the skin package

You can rename night.apk to night.skin by yourself.

Load plug-in skin package

You can put the skin package into the assets/skins directory.

SkinCompatManager.getInstance().loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS);

Or you can customize the loading strategy:

For example:

Inherit from SkinSDCardLoader,Rewrite the getSkinPathgetType methods。

public class CustomSDCardLoader extends SkinSDCardLoader {
    public static final int SKIN_LOADER_STRATEGY_SDCARD = Integer.MAX_VALUE;

    @Override
    protected String getSkinPath(Context context, String skinName) {
        return new File(SkinFileUtils.getSkinDir(context), skinName).getAbsolutePath();
    }

    @Override
    public int getType() {
        return SKIN_LOADER_STRATEGY_SDCARD;
    }
}

Register this strategy in Application's onCreate

SkinCompatManager.withoutActivity(this).addStrategy(new CustomSDCardLoader());

Use this strategy to load skin:

SkinCompatManager.getInstance().loadSkin("night.skin", null, CustomSDCardLoader.SKIN_LOADER_STRATEGY_SDCARD);

About Author

Pengfeng Wang(王鹏锋)

email: [email protected]

android-skin-support's People

Contributors

jungle68 avatar ximsfei avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.