【发布时间】:2020-01-25 01:59:30
【问题描述】:
如何更改layout 中星形组件的颜色? 可以在代码下面完成还是我必须在 xml 中工作?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Custom);
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"));
layout.setBackgroundColor(0xffff0000);
setContentView(layout); }
【问题讨论】:
-
这能回答你的问题吗? Android: Change color of ratingbar to golden
-
也有一些较旧的答案,但我猜较新的答案在 2020 年有效。旧的答案:Android RatingBar change star colors
-
我的问题是 RatingBar 等添加了代码,它们在布局设计中不存在。如何访问这些变量?
标签: android