コード例 #1
0
ファイル: RatingBar.java プロジェクト: BvbKoala/SourceCode
  public RatingBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RatingBar, defStyle, 0);
    final int numStars = a.getInt(R.styleable.RatingBar_numStars, mNumStars);
    setIsIndicator(a.getBoolean(R.styleable.RatingBar_isIndicator, !mIsUserSeekable));
    final float rating = a.getFloat(R.styleable.RatingBar_rating, -1);
    final float stepSize = a.getFloat(R.styleable.RatingBar_stepSize, -1);
    a.recycle();

    if (numStars > 0 && numStars != mNumStars) {
      setNumStars(numStars);
    }

    if (stepSize >= 0) {
      setStepSize(stepSize);
    } else {
      setStepSize(0.5f);
    }

    if (rating >= 0) {
      setRating(rating);
    }

    // A touch inside a star fill up to that fractional area (slightly more
    // than 1 so boundaries round up).
    mTouchProgressOffset = 1.1f;
  }
コード例 #2
0
ファイル: ZRatingBar.java プロジェクト: tinyao/DouMovie
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    ratingBar = (RatingBar) findViewById(R.id.zrb_rating);
    ratingTv = (TextView) findViewById(R.id.ztv_rating);
    ratingBar.setNumStars(numStars);
    ratingBar.setStepSize(stepSize);
    ratingBar.setMax(max);
    ratingBar.setRating(rating);
    ratingBar.setIsIndicator(isIndicator);
    ratingTv.setTextSize(mTextSize / getResources().getDisplayMetrics().density);
    ratingTv.setTextColor(mTextColor);

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(0, 0, mSpacing, 0);
    ratingBar.setLayoutParams(layoutParams);
  }
コード例 #3
0
 @Override
 protected void init() {
   ViewUtils.inject(this);
   top_tv_title.setText("Comment");
   ratingBar.setIsIndicator(true);
 }