<repo_name>ContentCoderJian/RatingBarDemo2<file_sep>/app/src/main/java/com/example/mirsfang/ratingbardemo/MainActivity.java
package com.example.mirsfang.ratingbardemo;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {
    private static final String TAG="MyRatingBar";
    Double a = 1.5;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        RatingBar mRatingBar = (RatingBar) findViewById(R.id.ratingbar);

        //点击之后的回调
        mRatingBar.setOnRatingChangeListener(
                new RatingBar.OnRatingChangeListener() {
                    @Override
                    public void onRatingChange(float RatingCount) {
                        Log.e(TAG,RatingCount+"");
                    }
                }
        );

        //优先设置一定数量下的星星样式
        RatingBar.Changed changed=mRatingBar.getChanged();
        changed.setPosintion(2);
        changed.setChangeDrawable(getResources().getDrawable(R.drawable.grabhb_yellow));
        changed.setChangeHarlfDrawable(getResources().getDrawable(R.drawable.grabhb_yellowhalf));
        mRatingBar.setChanged(changed);
        //设置星星
        mRatingBar.setStar(a.floatValue());

        //设置正常下的星星的样式
        mRatingBar.setmClickable(true);
        mRatingBar.setStarImageSize(16f);
        mRatingBar.setStarFillDrawable(getResources().getDrawable(R.drawable.grabhb_red));
        mRatingBar.setStarHalfDrawable(getResources().getDrawable(R.drawable.grabhb_halfred));

    }
}
<file_sep>/README.md
# RatingBarDemo2
自定义RatingBar,可以根据设置星星的数量改变样式

能设置在哪个星星哪里改变样式，能自由控制大小，更换图片

![image](http://img.blog.csdn.net/20160412144607361?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center) 
