CoderAlee / PaintedSkin

一款解决Android App 换肤框架,极低的侵入性与学习成本。
Apache License 2.0
166 stars 23 forks source link

功能咨询:皮肤没办法切换 #41

Closed SakurajimaMaii closed 10 months ago

SakurajimaMaii commented 10 months ago

问题描述

}

// 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}")
}

https://github.com/CoderAlee/PaintedSkin/assets/46998172/d596bd71-3966-478f-ac65-577cf3fb829e

日志

image

SakurajimaMaii commented 10 months ago

发现是资源名错了,问题已经解决