當前位置: 首頁>>代碼示例>>Java>>正文


Java Paint.setColor方法代碼示例

本文整理匯總了Java中android.graphics.Paint.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.setColor方法的具體用法?Java Paint.setColor怎麽用?Java Paint.setColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.setColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addArrowView

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.START;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.END;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    if (Gravity.isVertical(((FrameLayout.LayoutParams) getLayoutParams()).gravity)) {
        // This is only true if there wasn't room for the container next to the icon,
        // so we centered it instead. In that case we don't want to show the arrow.
        arrowView.setVisibility(INVISIBLE);
    } else {
        ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
                width, height, !mIsAboveIcon));
        Paint arrowPaint = arrowDrawable.getPaint();
        // Note that we have to use getChildAt() instead of getItemViewAt(),
        // since the latter expects the arrow which hasn't been added yet.
        PopupItemView itemAttachedToArrow = (PopupItemView)
                (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0));
        arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon));
        // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
        int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
        arrowPaint.setPathEffect(new CornerPathEffect(radius));
        arrowView.setBackground(arrowDrawable);
        arrowView.setElevation(getElevation());
    }
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:44,代碼來源:PopupContainerWithArrow.java

示例2: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init() {
    setLayerType(LAYER_TYPE_SOFTWARE,null);
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setStrokeWidth(1);
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.RED);

    mPath = new Path();


    anim = ValueAnimator.ofFloat(0f,1f);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(5000);
    anim.setRepeatCount(ValueAnimator.INFINITE);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            progress = (float)animation.getAnimatedValue();
            invalidate();
        }
    });

    anim.start();

}
 
開發者ID:fanxiaole,項目名稱:Garbage_RippleView,代碼行數:27,代碼來源:RippleView.java

示例3: cropCircle

import android.graphics.Paint; //導入方法依賴的package包/類
public Bitmap cropCircle(Bitmap bitmap) {
	Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
	Canvas canvas = new Canvas(output);

	final int color = 0xff424242;
	final Paint paint = new Paint();
	final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

	paint.setAntiAlias(true);
	canvas.drawARGB(0, 0, 0, 0);
	paint.setColor(color);
	canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
			bitmap.getWidth() / 2, paint);
	paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
	canvas.drawBitmap(bitmap, rect, rect, paint);
	return output;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:18,代碼來源:ButtonFloat.java

示例4: drawHrozontal

import android.graphics.Paint; //導入方法依賴的package包/類
private void drawHrozontal(Canvas c, RecyclerView parent) {
        int childCount = parent.getChildCount();
        if (childCount<1)return;
//        int left = parent.getPaddingLeft()+leftView.getLeft()+leftView.getPaddingLeft();
        int top = parent.getPaddingTop();
        int bottom = parent.getHeight() - parent.getPaddingBottom();

        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.LTGRAY);
        for (int i = 0; i < childCount-1; i++) {
            View child = parent.getChildAt(i);
            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                    .getLayoutParams();
            int left = child.getRight()+params.rightMargin;
            int right = left + 1;
            c.drawRect(left, top, right, bottom, paint);

        }
    }
 
開發者ID:piyell,項目名稱:NeteaseCloudMusic,代碼行數:20,代碼來源:LineItemDecorator.java

示例5: drawTimeLabels

import android.graphics.Paint; //導入方法依賴的package包/類
public void drawTimeLabels(Canvas canvas) {
    int px = rulerStartX;
    py = TIME_LABEL_FONT_SIZE + TIME_LABEL_VERTICAL_PADDING;

    Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextSize(TIME_LABEL_FONT_SIZE);
    mTextPaint.setColor(Color.LTGRAY);

    for (int i = 0; i < totalHours; i++) {
        String displayText = String.format("%02d:00", initialHour + i);
        float textWidth = mTextPaint.measureText(displayText);
        canvas.drawText(displayText, px, py, mTextPaint);
        labelXPosition[i] = px;
        px += textWidth + 10;
    }

    viewWidth = px;

    py += TIME_LABEL_VERTICAL_PADDING;

    canvas.drawLine(0, py, viewWidth, py, mTextPaint);
}
 
開發者ID:z3phyro,項目名稱:android-agenda-view,代碼行數:23,代碼來源:AgendaView.java

示例6: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
    mContext = context;
    TypedArray ta = mContext.getTheme().obtainStyledAttributes(attrs,R.styleable.RingChartView,0,0);
    mChartRadius = ta.getDimension(R.styleable.RingChartView_bigRingRadius,DEFAULT_RING_RADIUS);
    mCenterRadius = ta.getDimension(R.styleable.RingChartView_smallCircleRadius,DEFAULT_CENTER_RADIUS);
    mTextSize =ta.getDimension(R.styleable.RingChartView_ringTextSize,DEFAULT_TEXTSIZE);
    ta.recycle();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.FILL);

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setTextSize(mTextSize);
    textPaint.setColor(mTextColor);

    wcPath = new Path();
}
 
開發者ID:HStanN,項目名稱:SimpleCustomizeView,代碼行數:18,代碼來源:RingChartView.java

示例7: BorderedText

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Create a bordered text object with the specified interior and exterior colors, text size and
 * alignment.
 *
 * @param interiorColor the interior text color
 * @param exteriorColor the exterior text color
 * @param textSize text size in pixels
 */
public BorderedText(final int interiorColor, final int exteriorColor, final float textSize) {
  interiorPaint = new Paint();
  interiorPaint.setTextSize(textSize);
  interiorPaint.setColor(interiorColor);
  interiorPaint.setStyle(Style.FILL);
  interiorPaint.setAntiAlias(false);
  interiorPaint.setAlpha(255);

  exteriorPaint = new Paint();
  exteriorPaint.setTextSize(textSize);
  exteriorPaint.setColor(exteriorColor);
  exteriorPaint.setStyle(Style.FILL_AND_STROKE);
  exteriorPaint.setStrokeWidth(textSize / 8);
  exteriorPaint.setAntiAlias(false);
  exteriorPaint.setAlpha(255);

  this.textSize = textSize;
}
 
開發者ID:apacha,項目名稱:TensorflowAndroidDemo,代碼行數:27,代碼來源:BorderedText.java

示例8: initPaints

import android.graphics.Paint; //導入方法依賴的package包/類
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setColor(textColorOut);
    paintOuterText.setAntiAlias(true);
    paintOuterText.setTypeface(Typeface.MONOSPACE);
    paintOuterText.setTextSize(textSize);

    paintCenterText = new Paint();
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setAntiAlias(true);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(Typeface.MONOSPACE);
    paintCenterText.setTextSize(textSize);

    paintIndicator = new Paint();
    paintIndicator.setColor(dividerColor);
    paintIndicator.setAntiAlias(true);

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}
 
開發者ID:crazysunj,項目名稱:Android-PickerDialog,代碼行數:23,代碼來源:WheelView.java

示例9: otherInit

import android.graphics.Paint; //導入方法依賴的package包/類
private void otherInit() {
    // Other initialization
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint
            .setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:20,代碼來源:BezelImageView.java

示例10: draw

import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top,
                 int y, int bottom, @NonNull Paint paint) {
    RectF rect = new RectF(x, top, x + measureText(paint, text, start, end), bottom);

    Paint rectPaint = new Paint(paint);
    rectPaint.setAntiAlias(true);
    rectPaint.setStrokeWidth(2);
    rectPaint.setStyle(Paint.Style.STROKE);
    rectPaint.setColor(color);
    canvas.drawRect(rect, rectPaint);

    canvas.drawText(text, start, end, x, y, paint);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:15,代碼來源:ErrorSpan.java

示例11: drawPath2

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 畫線   一天線
 *
 * @param canvas
 */
private void drawPath2(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(Color.BLUE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    Path path = new Path();
    path.lineTo(100, 100);
    path.rLineTo(100, 0); //r 是相對路徑 意思是從上次的(100,100)為起點,相對來說畫一條向右 100 的直線
    path.quadTo(100, 100, 500, 500);
    canvas.drawPath(path, paint);
}
 
開發者ID:songjiabin,項目名稱:MySelfDemo,代碼行數:17,代碼來源:MyView2.java

示例12: toRoundCorner

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 轉為圓角圖片
 *
 * @param src         源圖片
 * @param radius      圓角的度數
 * @param borderSize  邊框尺寸
 * @param borderColor 邊框顏色
 * @param recycle     是否回收
 * @return 圓角圖片
 */
public static Bitmap toRoundCorner(final Bitmap src, final float radius, int borderSize, int borderColor, final boolean recycle) {
	if (isEmptyBitmap(src)) {
		return null;
	}
	int width = src.getWidth();
	int height = src.getHeight();
	Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
	BitmapShader shader = new BitmapShader(src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
	paint.setShader(shader);
	Canvas canvas = new Canvas(ret);
	RectF rectF = new RectF(0, 0, width, height);
	float halfBorderSize = borderSize / 2f;
	rectF.inset(halfBorderSize, halfBorderSize);
	canvas.drawRoundRect(rectF, radius, radius, paint);
	if (borderSize > 0) {
		paint.setShader(null);
		paint.setColor(borderColor);
		paint.setStyle(Paint.Style.STROKE);
		paint.setStrokeWidth(borderSize);
		paint.setStrokeCap(Paint.Cap.ROUND);
		canvas.drawRoundRect(rectF, radius, radius, paint);
	}
	if (recycle && !src.isRecycled()) {
		src.recycle();
	}
	return ret;
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:39,代碼來源:ImageUtils.java

示例13: SpringBar

import android.graphics.Paint; //導入方法依賴的package包/類
public SpringBar(Context context, int springColor, float maxRadiusPercent, float minRadiusPercent) {
    super(context);
    this.maxRadiusPercent = maxRadiusPercent;
    this.minRadiusPercent = minRadiusPercent;
    foot = new Point();
    head = new Point();
    path = new Path();
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL_AND_STROKE);
    paint.setStrokeWidth(1);
    paint.setColor(springColor);
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:14,代碼來源:SpringBar.java

示例14: transform

import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());

    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
    if (squaredBitmap != source) {
        source.recycle();
    }

    Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setAntiAlias(true);

    float r = size / 2f;

    // Prepare the background
    Paint paintBg = new Paint();
    paintBg.setColor(BORDER_COLOR);
    paintBg.setAntiAlias(true);

    // Draw the background circle
    canvas.drawCircle(r, r, r, paintBg);

    // Draw the image smaller than the background so a little border will be seen
    canvas.drawCircle(r, r, r - BORDER_RADIUS, paint);

    squaredBitmap.recycle();
    return bitmap;
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:37,代碼來源:BorderedCircleTransformation.java

示例15: initEntityBorder

import android.graphics.Paint; //導入方法依賴的package包/類
private void initEntityBorder(@NonNull MotionEntity entity ) {
  // init stroke
  int strokeSize = getResources().getDimensionPixelSize(R.dimen.scribble_stroke_size);
  Paint borderPaint = new Paint();
  borderPaint.setStrokeWidth(strokeSize);
  borderPaint.setAntiAlias(true);
  borderPaint.setColor(getContext().getResources().getColor(R.color.sticker_selected_color));

  entity.setBorderPaint(borderPaint);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:11,代碼來源:MotionView.java


注:本文中的android.graphics.Paint.setColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。