有时候需要动态的获取当前主题中设置的属性,例如文字颜色、背景等等,这个时候就可以利用obtainStyledAttributes方法获取,代码如下:

 TypedArray a = this.getTheme().obtainStyledAttributes(new int[]  {android.R.attr.colorPrimaryDark});
 int statusBarColor = a.getColor(0, Color.WHITE);
 a.recycle();

相关文章:

  • 2021-12-24
  • 2021-05-17
  • 2022-12-23
  • 2021-11-27
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-01-14
相关资源
相似解决方案