Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使分级栏图标变小_Android - Fatal编程技术网

Android 如何使分级栏图标变小

Android 如何使分级栏图标变小,android,Android,nelow是工作的示例代码,如何使评级栏图标变小?如果我加上这一行 style=“?android:attr/ratingBarStyleSmall”那么评级栏不工作为什么?hw使评级图标变小请帮助我 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="f

nelow是工作的示例代码,如何使评级栏图标变小?如果我加上这一行 style=“?android:attr/ratingBarStyleSmall”那么评级栏不工作为什么?hw使评级图标变小请帮助我

  <?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" >

<TextView
    android:id="@+id/lblRateMe"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text_label_1"
    android:textAppearance="?android:attr/textAppearanceMedium" />

 <RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:numStars="4"
    android:stepSize="1.0"
    android:rating="2.0" />

  <Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label" />

 <LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/lblResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/text_label_2"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/txtRatingValue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceSmall" />

  </LinearLayout>

   </LinearLayout>

我建议您使用自定义图标制作自己的
分级栏
。请看,尝试将android:isIndicator=“false”添加到您的分级栏
public class MainActivity extends Activity {


 private RatingBar ratingBar;
 private TextView ratingValue;
 private Button button;

  @Override
    public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

addListenerOnRatingBar();
addListenerOnButton();

    }

 public void addListenerOnRatingBar() {

ratingBar = (RatingBar) findViewById(R.id.ratingBar);
ratingValue = (TextView) findViewById(R.id.txtRatingValue);


ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

    public void onRatingChanged(RatingBar ratingBar, float rating,  boolean fromUser) {

        ratingValue.setText(String.valueOf(rating));

    }
});
  }

  public void addListenerOnButton() {

ratingBar = (RatingBar) findViewById(R.id.ratingBar);
button = (Button) findViewById(R.id.button);


button.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {

    Toast.makeText(MainActivity.this, String.valueOf(ratingBar.getRating()),     
  Toast.LENGTH_LONG).show();
    }

});

 }
 }