[英]How to set custom theme attribute programmatically in Android 10
在 styles.xml 中可以輕松更改主題屬性,並在 attrs.xml 中定義新的自定義主題屬性。
但是如何在 java 代碼中做到這一點?
在Activity中調用setTheme后,如何以編程方式更改或定義屬性?
測試活動.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Apply "AppTheme" to this Activity super.setTheme(R.style.AppTheme); // How to change theme attribute "colorPrimary" or "android.R.attr.colorPrimary" in here? // How to define new custom theme attribute "customThemeAttribute" in here? }
謝謝。
經過一番研究,沒有辦法以編程方式設置主題屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.