コード例 #1
0
  @SuppressWarnings("NullableProblems")
  @Override
  protected void onDraw(Canvas canvas) {

    // Draw Title Text
    if (mAttributes.isShowTitle()
        && mTitlePaint != null
        && mCurTitleProperty != null
        && mCurTitleProperty.mAlpha != 0) {
      CharSequence buf = getHint();
      if (buf != null) {
        mTitlePaint.setTextSize(mCurTitleProperty.mTextSize);

        int color = getCurrentTitleTextColor();
        int alpha = GeniusUi.modulateAlpha(Color.alpha(color), mCurTitleProperty.mAlpha);

        mTitlePaint.setColor(color);
        mTitlePaint.setAlpha(alpha);

        canvas.drawText(
            buf,
            0,
            buf.length(),
            mCurTitleProperty.mPaddingLeft,
            mCurTitleProperty.mPaddingTop + mCurTitleProperty.mTextSize,
            mTitlePaint);
      }
    }

    super.onDraw(canvas);
  }
コード例 #2
0
ファイル: Effect.java プロジェクト: 80245089/Genius-Android
 /**
  * Set the draw paint alpha by modulateAlpha
  *
  * @param paint Paint
  * @param alpha Alpha
  * @return PrevAlpha
  */
 protected int setPaintAlpha(Paint paint, int alpha) {
   final int prevAlpha = paint.getAlpha();
   paint.setAlpha(GeniusUi.modulateAlpha(prevAlpha, alpha));
   return prevAlpha;
 }