├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── attrs.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable-xhdpi │ │ │ │ ├── android.png │ │ │ │ ├── nanzhuang.png │ │ │ │ └── nanzhuang_night.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── layout │ │ │ │ ├── activity_web_view.xml │ │ │ │ ├── list_item.xml │ │ │ │ ├── activity_other.xml │ │ │ │ ├── activity_setting.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── activity_colormatrix.xml │ │ │ └── drawable │ │ │ │ ├── btn_round.xml │ │ │ │ └── btn_round_night.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── maning │ │ │ │ └── androidchangeskindemo │ │ │ │ ├── app │ │ │ │ └── MyApplication.java │ │ │ │ ├── activity │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── OtherActivity.java │ │ │ │ ├── SettingActivity.java │ │ │ │ ├── WebViewActivity.java │ │ │ │ ├── other │ │ │ │ │ ├── ColorMatrixActivity.java │ │ │ │ │ └── ColorMatrixUtils.java │ │ │ │ └── MainActivity.java │ │ │ │ └── adapter │ │ │ │ └── SkinAdapter.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── maning │ │ │ └── androidchangeskindemo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── maning │ │ └── androidchangeskindemo │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── themelibrary ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ └── strings.xml │ │ │ └── anim │ │ │ │ ├── mn_theme_activity_enter.xml │ │ │ │ └── mn_theme_activity_exit.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── maning │ │ │ └── themelibrary │ │ │ ├── SkinBroadcastReceiver.java │ │ │ └── SkinManager.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── maning │ │ │ └── themelibrary │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── maning │ │ └── themelibrary │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── screenshots └── 001.gif ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /themelibrary/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':themelibrary' 2 | -------------------------------------------------------------------------------- /screenshots/001.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/screenshots/001.gif -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MNChangeSkin 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /themelibrary/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ThemeLibrary 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/drawable-xhdpi/android.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/nanzhuang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/drawable-xhdpi/nanzhuang.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/nanzhuang_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maning0303/MNChangeSkin/HEAD/app/src/main/res/drawable-xhdpi/nanzhuang_night.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 21 11:34:03 PDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /themelibrary/src/main/res/anim/mn_theme_activity_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /themelibrary/src/main/res/anim/mn_theme_activity_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /themelibrary/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/maning/androidchangeskindemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/maning/androidchangeskindemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_web_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /themelibrary/src/test/java/com/maning/themelibrary/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.maning.themelibrary; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_round_night.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/maning/androidchangeskindemo/app/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo.app; 2 | 3 | import android.app.Application; 4 | 5 | import com.maning.androidchangeskindemo.R; 6 | import com.maning.themelibrary.SkinManager; 7 | 8 | /** 9 | * Created by maning on 2017/6/5. 10 | */ 11 | 12 | public class MyApplication extends Application { 13 | 14 | @Override 15 | public void onCreate() { 16 | super.onCreate(); 17 | 18 | initTheme(); 19 | } 20 | 21 | private void initTheme() { 22 | SkinManager.setThemeID(R.style.DayTheme, R.style.NightTheme); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /themelibrary/src/main/java/com/maning/themelibrary/SkinBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | package com.maning.themelibrary; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | /** 8 | * Created by maning on 16/3/29. 9 | * 接收主题改变的广播 10 | */ 11 | public abstract class SkinBroadcastReceiver extends BroadcastReceiver { 12 | 13 | @Override 14 | public void onReceive(Context context, Intent intent) { 15 | int currentTheme = intent.getIntExtra(SkinManager.IntentExtra_SkinTheme, 0); 16 | onChangeSkin(currentTheme); 17 | } 18 | 19 | public void onChangeSkin(int currentTheme) { 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/maning/androidchangeskindemo/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo.activity; 2 | 3 | import android.os.Bundle; 4 | import androidx.appcompat.app.AppCompatActivity; 5 | 6 | import com.maning.themelibrary.SkinManager; 7 | 8 | /** 9 | * Created by maning on 16/3/28. 10 | */ 11 | public class BaseActivity extends AppCompatActivity { 12 | 13 | //当前Activity的主题 14 | public int skinBase; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | //设置主题 19 | SkinManager.onActivityCreateSetSkin(this); 20 | super.onCreate(savedInstanceState); 21 | //获取当前的主题 22 | skinBase = SkinManager.getCurrentSkinType(this); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /themelibrary/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/maning/Develop/Android/SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/maning/Desktop/Android/AndroidStudioSDK/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /themelibrary/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.maning0303' 5 | 6 | android { 7 | compileSdkVersion 28 8 | buildToolsVersion "28.0.3" 9 | 10 | defaultConfig { 11 | minSdkVersion 16 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | } 30 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.maning.androidchangeskindemo" 9 | minSdkVersion 16 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(include: ['*.jar'], dir: 'libs') 24 | implementation 'androidx.appcompat:appcompat:1.0.0' 25 | implementation 'com.kyleduo.switchbutton:library:1.3.4' 26 | implementation project(':themelibrary') 27 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' 28 | } 29 | -------------------------------------------------------------------------------- /themelibrary/src/androidTest/java/com/maning/themelibrary/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.maning.themelibrary; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.maning.themelibrary.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #ffffff 7 | 8 | 9 | #fafafa 10 | #3b3b3b 11 | #fdfdfd 12 | #cccccc 13 | #ffffff 14 | #ffffff 15 | #bebebe 16 | 17 | 18 | #232736 19 | #626f9b 20 | #232736 21 | #5a6285 22 | #2A2F41 23 | #232736 24 | #5a6285 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_other.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 14 | 15 | 21 | 22 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 31 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/maning/androidchangeskindemo/activity/OtherActivity.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.View; 7 | 8 | import com.maning.androidchangeskindemo.R; 9 | import com.maning.themelibrary.SkinBroadcastReceiver; 10 | import com.maning.themelibrary.SkinManager; 11 | 12 | public class OtherActivity extends BaseActivity { 13 | 14 | 15 | private SkinBroadcastReceiver skinBroadcastReceiver; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_other); 21 | 22 | findViewById(R.id.rl_setting).setOnClickListener(new View.OnClickListener() { 23 | @Override 24 | public void onClick(View v) { 25 | startActivity(new Intent(OtherActivity.this, SettingActivity.class)); 26 | } 27 | }); 28 | 29 | registerSkinReceiver(); 30 | 31 | } 32 | 33 | public void registerSkinReceiver() { 34 | skinBroadcastReceiver = new SkinBroadcastReceiver() { 35 | @Override 36 | public void onChangeSkin(int currentTheme) { 37 | Log.i("onChangeSkin", "OtherActivity广播来了" + currentTheme); 38 | //重启Activity 39 | recreate(); 40 | } 41 | }; 42 | SkinManager.registerSkinReceiver(OtherActivity.this, skinBroadcastReceiver); 43 | } 44 | 45 | public void unregisterSkinReceiver() { 46 | if (skinBroadcastReceiver != null) { 47 | SkinManager.unregisterSkinReceiver(this, skinBroadcastReceiver); 48 | } 49 | } 50 | 51 | 52 | @Override 53 | protected void onDestroy() { 54 | super.onDestroy(); 55 | unregisterSkinReceiver(); 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/maning/androidchangeskindemo/adapter/SkinAdapter.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.maning.androidchangeskindemo.R; 12 | 13 | /** 14 | * Created by maning on 16/3/28. 15 | */ 16 | public class SkinAdapter extends BaseAdapter { 17 | 18 | private Context context; 19 | private LayoutInflater inflater; 20 | 21 | public SkinAdapter(Context context) { 22 | this.context = context; 23 | inflater = LayoutInflater.from(this.context); 24 | } 25 | 26 | 27 | @Override 28 | public int getCount() { 29 | return 10; 30 | } 31 | 32 | @Override 33 | public Object getItem(int position) { 34 | return null; 35 | } 36 | 37 | @Override 38 | public long getItemId(int position) { 39 | return 0; 40 | } 41 | 42 | @Override 43 | public View getView(int position, View convertView, ViewGroup parent) { 44 | ViewHolder viewHolder; 45 | if (convertView == null) { 46 | viewHolder = new ViewHolder(); 47 | convertView = inflater.inflate(R.layout.list_item, parent, false); 48 | viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView); 49 | viewHolder.textView = (TextView) convertView.findViewById(R.id.textView); 50 | convertView.setTag(viewHolder); 51 | } else { 52 | viewHolder = (ViewHolder) convertView.getTag(); 53 | } 54 | viewHolder.textView.setText("这是男装" + position); 55 | 56 | return convertView; 57 | } 58 | 59 | private static class ViewHolder { 60 | ImageView imageView; 61 | TextView textView; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 20 | 21 | 29 | 30 | 47 | 48 | 49 | 50 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/maning/androidchangeskindemo/activity/SettingActivity.java: -------------------------------------------------------------------------------- 1 | package com.maning.androidchangeskindemo.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.widget.CompoundButton; 7 | 8 | import com.kyleduo.switchbutton.SwitchButton; 9 | import com.maning.androidchangeskindemo.R; 10 | import com.maning.themelibrary.SkinManager; 11 | 12 | public class SettingActivity extends BaseActivity { 13 | 14 | private static final String TAG = "SettingActivity"; 15 | private SwitchButton btn_checked; 16 | private Context context; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_setting); 22 | 23 | context = this; 24 | 25 | btn_checked = (SwitchButton) findViewById(R.id.btn_checked); 26 | 27 | int currentSkinType = SkinManager.getCurrentSkinType(SettingActivity.this); 28 | if (SkinManager.THEME_DAY == currentSkinType) { 29 | btn_checked.setCheckedImmediately(false); 30 | btn_checked.setBackColorRes(R.color.kswBackColor); 31 | btn_checked.setThumbColorRes(R.color.kswThumbColor); 32 | } else { 33 | btn_checked.setCheckedImmediately(true); 34 | btn_checked.setBackColorRes(R.color.kswBackColor_night); 35 | btn_checked.setThumbColorRes(R.color.kswThumbColor_night); 36 | } 37 | 38 | btn_checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 39 | @Override 40 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 41 | SkinManager.changeSkin(SettingActivity.this); 42 | resetActivity(); 43 | } 44 | }); 45 | 46 | } 47 | 48 | //重启当前Activity 49 | private void resetActivity() { 50 | startActivity(new Intent(this, SettingActivity.class)); 51 | overridePendingTransition(com.maning.themelibrary.R.anim.mn_theme_activity_enter, com.maning.themelibrary.R.anim.mn_theme_activity_exit); 52 | finish(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |