Closed SakurajimaMaii closed 10 months ago
在 Application 中进行配置
class App : Application() { override fun onCreate() { super.onCreate() WindowManager.getInstance().init(this, OptionFactory()) } init{ Config.getInstance().skinMode = Config.SkinMode.REPLACE_ALL Config.getInstance().isEnableDebugMode = true Config.getInstance().performanceMode = Config.PerformanceMode.EXPERIENCE_FIRST }
}
// OptionFactory 声明 class OptionFactory : IOptionFactory { override fun defaultTheme(): Int { return 0 }
override fun requireOption(theme: Int): IThemeSkinOption? { return when (theme) { 1 -> NightOption() else -> null } }
private class NightOption : IThemeSkinOption { override fun getStandardSkinPackPath(): LinkedHashSet { val pathSet = LinkedHashSet() pathSet.add("${FileMgr.appInternalFilesDir().path}/app-skin.skin") return pathSet } }
- 切换皮肤 ```kotlin SpEncryptedExample.isDark = false mBinding.changeDark.setOnClickListener { if (SpEncryptedExample.isDark) { ThemeSkinService.getInstance().switchThemeSkin(0) SpEncryptedExample.isDark = false } else { ThemeSkinService.getInstance().switchThemeSkin(1) SpEncryptedExample.isDark = true } SimpleToast.showShortMsg("当前暗夜模式 ${SpEncryptedExample.isDark}") }
<ImageView android:layout_width="300dp" android:layout_height="300dp" android:scaleType="fitXY" android:src="@drawable/background" />
在完成上述步骤后,进行皮肤切换并无反应,视频如下
https://github.com/CoderAlee/PaintedSkin/assets/46998172/d596bd71-3966-478f-ac65-577cf3fb829e
发现是资源名错了,问题已经解决
问题描述
在 Application 中进行配置
}
// OptionFactory 声明 class OptionFactory : IOptionFactory { override fun defaultTheme(): Int { return 0 }
}
private class NightOption : IThemeSkinOption { override fun getStandardSkinPackPath(): LinkedHashSet {
val pathSet = LinkedHashSet()
pathSet.add("${FileMgr.appInternalFilesDir().path}/app-skin.skin")
return pathSet
}
}
在完成上述步骤后,进行皮肤切换并无反应,视频如下
https://github.com/CoderAlee/PaintedSkin/assets/46998172/d596bd71-3966-478f-ac65-577cf3fb829e
日志