Android RatingBar pokazuje więcej niż 5 gwiazdek

Chcę wyświetlić pasek oceny za pomocą okna dialogowego alertu w mojej aplikacji na Androida. Problem, z którym mam do czynienia, polega na tym, że w zależności od szerokości ekranu pasek oceny pokazuje więcej niż 5 gwiazdek (do 10) w trybie poziomym, a funkcja setNumStars () nie działa. Są już posty, które zajmują się tym problemem, ale zajmują się listą ratingową, której laout jest zdefiniowany statycznie, podczas gdy ja tworzę go dynamicznie. Jak rozwiązać ten problem?

public class MainActivity extends Activity {
private Button launchButton;
//Rating dialog
 private AlertDialog.Builder rater;
 private RatingBar ratingBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    launchButton =(Button)findViewById(R.id.ratingButton);
    launchButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            //Here the alert dialog will be launched
            showRatingDialog();
        }
    });

      //Setting up rating dialog
        rater = new AlertDialog.Builder(this);

        rater.setTitle("This is the rating dialog");


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
public void showRatingDialog()
{
  ratingBar = (RatingBar)findViewById(R.id.ratingStars);
      rater.setNegativeButton("Abbrechen", null);
      rater.setView(ratingBar);
      rater.show();

}
}

Próbowałem użyć układu statycznego dla paska oceniania, ale gdy to zrobię i spróbuję wyświetlić pasek oceny w oknie dialogowym alertu, nie są wyświetlane żadne gwiazdki. Oto plik układu paska oceny:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RatingBar
        android:id="@+id/ratingStars"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numStars="5"
        android:stepSize="1"
        />

</LinearLayout>

questionAnswers(4)

yourAnswerToTheQuestion