I have a fragment Feedback.java. there is a button which raises a popupwindow. I am creating a Rating bar in popup Window. My Custom Style for Rating bar is defined in XML files. i defined Style in values/styles.xml
<style name="RatingBar1" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/rating_bar_full</item>
<item name="android:minHeight">48dip</item>
<item name="android:maxHeight">48dip</item>
</style>
I have created RatingBar runtime with above style using following code.
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
param.setMarginStart(15);
float stepSize = (float) 0.5;
rating = new RatingBar(getActivity(), null,R.style.RatingBar1);
rating.setNumStars(5);
rating.setStepSize(stepSize);
but Rating bar is not showing. I know this is a problem that Styles are loaded onCreate() and we craete popup on ButtonClick. that is why Style is not applying. So how can i load Style at runtime for my RatingBar. Any Suggestion. Thanx Already!
this worked for me. you can set any color to stars on runtime for RatingBr. Try this.