【问题标题】:How to set custom theme attribute programmatically in Android 10如何在 Android 10 中以编程方式设置自定义主题属性
【发布时间】:2020-06-04 16:12:10
【问题描述】:

很容易在styles.xml中改变主题属性,在attrs.xml中定义新的自定义主题属性。

但是在java代码中怎么做呢?

在Activity中调用setTheme后,如何以编程方式改变或定义属性?

TestActivity.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?
}

谢谢。

【问题讨论】:

    标签: java android themes


    【解决方案1】:

    经过一番研究,没有办法以编程方式设置主题属性。

    【讨论】:

      猜你喜欢
      • 2016-06-12
      • 2015-11-22
      • 2013-05-26
      • 2011-03-15
      • 1970-01-01
      • 2015-01-14
      • 2021-06-22
      • 2023-01-03
      • 1970-01-01
      相关资源
      最近更新 更多