目前,我的AndroidManifest.xml
使用了第三方主题。
<application
...
android:theme="@style/Theme.JStock.Light" >
<!-- 3rd party library with 3rd party theme -->
<activity
android:name="group.pals.android.lib.ui.lockpattern.LockPatternActivity"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
android:screenOrientation="user"
android:theme="@style/Alp.Theme.Light" />
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.JStock.Light" parent="Theme.Sherlock.Light">
...
</style>
<style name="Theme.JStock.Dark" parent="Theme.Sherlock.Dark">
...
</style>
因为,我可能会在运行时更改我的应用主题
setTheme(R.style.Theme.JStock.Light);
或setTheme(R.style.Theme.JStock.Dark);
我希望有类似下面的内容,以便我的Java代码不需要关注第三方主题。
<application
...
android:theme="@style/Theme.JStock.Light" >
<!-- 3rd party library with 3rd party theme -->
<activity
android:name="group.pals.android.lib.ui.lockpattern.LockPatternActivity"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
android:screenOrientation="user"
android:theme="?attr/thirdPartyTheme" />
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.JStock.Light" parent="Theme.Sherlock.Light">
<item name="thirdPartyTheme">@style/Alp.Theme.Light</item>
...
</style>
<style name="Theme.JStock.Dark" parent="Theme.Sherlock.Dark">
<item name="thirdPartyTheme">@style/Alp.Theme.Dark</item>
...
</style>
当然,这会导致运行时错误。我可以知道,实现目标的正确方法是什么?