# Android-skin-support
[中文](../README.md) | In English
[![skin-support](https://img.shields.io/badge/release-v4.0.5-green.svg)](http://jcenter.bintray.com/skin/support)
![build](https://img.shields.io/badge/build-passing-green.svg)
![license](https://img.shields.io/badge/license-mit-blue.svg)
Android-skin-support is an easy skin framework to use for Android. The best case, Only one line of code to integrate the framework.
```java
SkinCompatManager.withoutActivity(this).loadSkin();
```
Now, you have a strong skinning feature. What you need to do is [make a skin](#make-a-skin).
![default](https://github.com/ximsfei/Res/blob/master/skin/preview/default.png)
![app-in](https://github.com/ximsfei/Res/blob/master/skin/preview/app-in.png)
![plug-in](https://github.com/ximsfei/Res/blob/master/skin/preview/plug-in.png)
## Table of Contents
* [Gradle Dependencies](#gradle-dependencies)
* [Integration](#integration)
* [Initialization](#initialization)
* [Load Skin](#load-skin)
* [Custom View skin support](#custom-view-skin-support)
* [Make a skin](#make-a-skin)
* [BuildIn Skin](#buildin-skin)
* [Plug-In Skin](#plug-in-skin)
* [Change Log](ChangeLog.md)
* [Who Use It](#who-use-it)
* [About Author](#about-author)
* [LICENSE](#license-mit)
## Gradle Dependencies
The Gradle Dependency is available via [jCenter](https://bintray.com/pengfeng/skin-support),
[For the latest version, please refer to change log](ChangeLog.md)
Add dependencies for [AndroidX](https://developer.android.com/topic/libraries/support-library/androidx-overview)
```xml
implementation 'skin.support:skin-support:4.0.5' // skin-support
implementation 'skin.support:skin-support-appcompat:4.0.5' // skin-support basic widget
implementation 'skin.support:skin-support-design:4.0.5' // skin-support-design material design support [selectable]
implementation 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView support [selectable]
implementation 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout support [selectable]
```
Add dependencies for support libraries
```xml
implementation 'skin.support:skin-support:3.1.4' // skin-support basic widget
implementation 'skin.support:skin-support-design:3.1.4' // skin-support-design material design support [selectable]
implementation 'skin.support:skin-support-cardview:3.1.4' // skin-support-cardview CardView support [selectable]
implementation 'skin.support:skin-support-constraint-layout:3.1.4' // skin-support-constraint-layout ConstraintLayout support [selectable]
```
## Integration
### Initialization
Only one line of code to integrate the framework.
```java
@Override
public void onCreate() {
super.onCreate();
SkinCompatManager.withoutActivity(this) // Basic Widget support
.addInflater(new SkinMaterialViewInflater()) // material design support [selectable]
.addInflater(new SkinConstraintViewInflater()) // ConstraintLayout support [selectable]
.addInflater(new SkinCardViewInflater()) // CardView v7 support [selectable]
.setSkinStatusBarColorEnable(false) // Disable statusBarColor skin support,default true [selectable]
.setSkinWindowBackgroundEnable(false) // Disable windowBackground skin support,default true [selectable]
.loadSkin();
}
```
> If your Activity inherits from AppCompatActivity, you need to override the getDelegate() method.
```java
@NonNull
@Override
public AppCompatDelegate getDelegate() {
return SkinAppCompatDelegateImpl.get(this, this);
}
```
### Load Skin
```java
// 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
1. Apply skin resource in the applySkin method
2. Resolve the skin resource id in the constructor
* Custom View can inherit directly from existing widget, such as `SkinCompatView`, `SkinCompatLinearLayout`, etc.
eg: [CustomTextView](../demo/skin-app/src/main/java/com/ximsfei/skindemo/widget/CustomTextView.java)
* if you don't want to inherit from existing widget.
eg: [CustomTextView2](../demo/skin-app/src/main/java/com/ximsfei/skindemo/widget/CustomTextView2.java)
* If you need to skin the custom attributes.
// such as AutoCompleteTextView's R.attr.popupBackground attribute
eg: [SkinCompatAutoCompleteTextView](../androidx/skin-support/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java)
* If you need to use third-party library.
// need to use https://github.com/hdodenhof/CircleImageView widget
eg: [SkinCompatCircleImageView](../third-part-support/circleimageview/src/main/java/skin/support/circleimageview/widget/SkinCompatCircleImageView.java)
## 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:
```java
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
```xml
sohu newsclient lite | voice note | qoo app | dwnews |