How can I change color of star components in this layout? Can it be done it below code or do I have to work in 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); }
You should have a reference of your layout components:
private ProgressBar progressBar;
private RadioButton radioButton;
private RatingButton ratingButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Custom);
ViewGroup layout = getLayout(getIntent().getStringExtra("key1"));
if (layout == null) return;
progressBar = new ProgressBar(this);
radioButton = new RadioButton(this);
ratingButton = new RatingButton(this);
layout.addView(progressBar);
layout.addView(radioButton);
layout.addView(ratingBar);
progressBar.setBackgroundColor(...);
radioButton.setBackgroundColor(...);
ratingButton.setBackgroundColor(...);
//And so on, with the appropriate method for each View
layout.setBackgroundColor(Color.parseColor("#3333ff"));
layout.setBackgroundColor(0xffff0000);
setContentView(layout);
}
User contributions licensed under CC BY-SA 3.0