我正在創建一個應用程序,我想要更改完整應用程序的主題。即如果我點擊任何Button
說changeTheme它應該改變主題w.r.t Application
Context
。更改主題的完整應用程序
我試圖
OnClickListener onClick = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
getApplicationContext().setTheme(R.style.AppTheme1);
setContentView(R.layout.activity_main);
}
};
但這不是反映。是否有我需要把這樣我可以改變Application
Themes
添加styles.xml
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textColor">#ffffff</item>
</style>
<style name="AppTheme1" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textColor">#000000</item>
</style>
應用主題,體現在應用標籤 – Raghunandan
@ Raghunandan我在清單文件中應用了主題。但我需要更改主題運行時。 – Vaibs