【发布时间】:2020-01-22 05:31:31
【问题描述】:
对于我的主要活动,以下代码将主题设置为我的自定义主题:
setTheme(R.style.Custom);但是我从中得到的布局呢:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ViewGroup layout = getLayout(getIntent().getStringExtra("key1")); if (layout == null) return; layout.addView(new ProgressBar(this)); layout.addView(new RadioButton(this)); layout.addView(new RatingBar(this)); layout.addView(new CheckBox(this)); layout.addView(new Switch(this)); layout.addView(new SeekBar(this)); layout.setBackgroundColor(Color.parseColor("#3333ff")); setContentView(layout); }我想改变 ViewGroup 布局的主题,我试过了
layout.setTheme(R.style.Custom); but it didn't work, what's the correct function to do this这是我的主题代码:(是否可以更改星星的颜色,条 等等在这里?)
<style name="Custom" parent="Theme.AppCompat.DayNight">
<item name="colorPrimary">#99ff99</item>
<item name="colorPrimaryDark">#009933</item>
<item name="colorAccent">#f542e3</item>
</style>
【问题讨论】:
标签: android