Java Code Examples for android.graphics.Paint.setStrokeWidth()

The following are Jave code examples for showing how to use setStrokeWidth() of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: JKApp   File: MLImageView.java   View Source Code Vote up 6 votes
private void drawBorder(Canvas canvas){
    if(mBorderWidth > 0){
        Paint paint = new Paint();
        paint.setStrokeWidth(mBorderWidth);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(mBorderColor);
        paint.setAntiAlias(true);
        if (mShapeType == 0) {
            canvas.drawCircle(mWidth / 2, mHeight / 2, mWidth / 2, paint);
        } else {
            // 当ShapeType = 1 时 图片为圆角矩形
            RectF rectf = new RectF(0, 0, getWidth(), getHeight());
            canvas.drawRoundRect(rectf, mRadius, mRadius, paint);
        }
    }
}
 
Example 2
Project: leoapp-sources   File: StatistikViewBalken.java   View Source Code Vote up 6 votes
private void drawBackground() {
    canvasBack.drawColor(ContextCompat.getColor(getContext(), android.R.color.background_light));
    Paint p1 = new Paint();
    p1.setStrokeWidth(3);
    p1.setColor(ContextCompat.getColor(getContext(), R.color.colorBadMood));
    canvasBack.drawLine(0, baseLineY, width, baseLineY, p1);
    Paint p2 = new Paint();
    p2.setStrokeWidth(3);
    p2.setColor(ContextCompat.getColor(getContext(), R.color.colorDissatisfied));
    canvasBack.drawLine(0, baseLineY - abstandY, width, baseLineY - abstandY, p2);
    Paint p3 = new Paint();
    p3.setStrokeWidth(3);
    p3.setColor(ContextCompat.getColor(getContext(), R.color.colorNeutral));
    canvasBack.drawLine(0, baseLineY - (2 * abstandY), width, baseLineY - (2 * abstandY), p3);
    Paint p4 = new Paint();
    p4.setStrokeWidth(3);
    p4.setColor(ContextCompat.getColor(getContext(), R.color.colorSatisfied));
    canvasBack.drawLine(0, baseLineY - (3 * abstandY), width, baseLineY - (3 * abstandY), p4);
    Paint p5 = new Paint();
    p5.setStrokeWidth(3);
    p5.setColor(ContextCompat.getColor(getContext(), R.color.colorVerySatisfied));
    canvasBack.drawLine(0, baseLineY - (4 * abstandY), width, baseLineY - (4 * abstandY), p5);
}
 
Example 3
Project: ScrollableChart   File: LineDrawing.java   View Source Code Vote up 6 votes
private void init() {
  mLinePath = new Path();
  mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mLinePaint.setColor(0xFFF90382);
  mLinePaint.setStyle(Paint.Style.STROKE);
  mLinePaint.setStrokeWidth(10.0f);

  mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mTextPaint.setColor(Color.WHITE);
  mTextPaint.setTextSize(Util.sp2px(mContext, 13.0f));

  mBubblePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mBubblePaint.setColor(0xFF3B4DEC);

  mBubblePath = new Path();
  mBubbleRect = new RectF();
}
 
Example 4
Project: TripBuyer   File: WheelView.java   View Source Code Vote up 6 votes
/**
 * Draws rect for current value
 * @param canvas the canvas for drawing
 */
private void drawCenterRect(Canvas canvas) {
	int center = getHeight() / 2;
	int offset = (int) (getItemHeight() / 2 * 1.2);
	/*/ Remarked by wulianghuan 2014-11-27  使用自己的画线,而不是描边
	Rect rect = new Rect(left, top, right, bottom)
	centerDrawable.setBounds(bounds)
	centerDrawable.setBounds(0, center - offset, getWidth(), center + offset);
	centerDrawable.draw(canvas);
	//*/
	Paint paint = new Paint();
	paint.setColor(getResources().getColor(R.color.red_500));
	// 设置线宽
	paint.setStrokeWidth((float) 3);
	// 绘制上边直线
	canvas.drawLine(0, center - offset, getWidth(), center - offset, paint);
	// 绘制下边直线
	canvas.drawLine(0, center + offset, getWidth(), center + offset, paint);
	//*/
}
 
Example 5
Project: MobileMedia   File: UnderLinePageIndicator.java   View Source Code Vote up 6 votes
public UnderLinePageIndicator(Context context, AttributeSet attrs, int defStyle) {

		super(context, attrs, defStyle);
		
		setHorizontalScrollBarEnabled(false);

		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPageIndicator, defStyle, 0);

		selectedTextColor = a.getColor(R.styleable.TabPageIndicator_selectedTextColor,
				Color.parseColor("#F28300"));
		unSelectedTextColor = a.getColor(R.styleable.TabPageIndicator_unSelectedTextColor,
				Color.BLACK);
		tabWidth = (int) a.getDimension(R.styleable.TabPageIndicator_tagWidth, 0);
		mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle);

		addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
		
		//用来绘制滚动的下划线
		mPaint = new Paint();  
        mPaint.setColor(selectedTextColor); 
        mPaint.setStrokeWidth(lineHeight);

		setWillNotDraw(false);
	}
 
Example 6
Project: PasswordNotebook   File: LockPatternView.java   View Source Code Vote up 6 votes
/**
 * initialize paints
 */
private void initPaints(){
	defaultPaint = new Paint();
	defaultPaint.setColor(getResources().getColor(R.color.blue_78d2f6));
	defaultPaint.setStrokeWidth(2.0f);
	defaultPaint.setStyle(Style.STROKE);
	defaultPaint.setAntiAlias(true);
	
	selectPaint = new Paint();
	selectPaint.setColor(getResources().getColor(R.color.blue_00aaee));
	selectPaint.setStrokeWidth(3.0f);
	//selectPaint.setStyle(Style.STROKE);
	selectPaint.setAntiAlias(true);
	
	errorPaint = new Paint();
	errorPaint.setColor(getResources().getColor(R.color.red_f3323b));
	errorPaint.setStrokeWidth(3.0f);
	//errorPaint.setStyle(Style.STROKE);
	errorPaint.setAntiAlias(true);
}
 
Example 7
Project: PeSanKita-android   File: CanvasView.java   View Source Code Vote up 6 votes
public void render(Canvas canvas) {
  if (this.canvas == null) return;

  float scaleX = 1.0F * canvas.getWidth() / this.canvas.getWidth();
  float scaleY = 1.0F * canvas.getHeight() / this.canvas.getHeight();

  Matrix matrix = new Matrix();
  matrix.setScale(scaleX, scaleY);

  for (int i = 0; i < this.historyPointer; i++) {
    Path path   = this.pathLists.get(i);
    Paint paint = this.paintLists.get(i);

    Path scaledPath = new Path();
    path.transform(matrix, scaledPath);

    Paint scaledPaint = new Paint(paint);
    scaledPaint.setStrokeWidth(scaledPaint.getStrokeWidth() * scaleX);

    canvas.drawPath(scaledPath, scaledPaint);
  }
}
 
Example 8
Project: android-study   File: PathArc.java   View Source Code Vote up 5 votes
public void setViewPaint() {
  //绘制风格
  paint = new Paint();
  //去锯齿
  paint.setAntiAlias(true);
  //设置绘制颜色
  paint.setColor(getResources().getColor(android.R.color.holo_blue_light));
  //为了方便看Path的路径效果
  //设置绘制风格为空心
  paint.setStyle(Paint.Style.STROKE);
  //设置空心边框的宽度
  paint.setStrokeWidth(10);
}
 
Example 9
Project: ScaleRulerView   File: VerticalRulerView.java   View Source Code Vote up 5 votes
private void initPaint() {
    mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setColor(bgColor);

    mShortLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mShortLinePaint.setColor(Color.WHITE);
    mShortLinePaint.setStrokeWidth(mShortLineWidth);

    mHighLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mHighLinePaint.setColor(Color.WHITE);
    mHighLinePaint.setStrokeWidth(mHighLineWidth);

    mIndicatorTxtPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mIndicatorTxtPaint.setColor(keduColor);
    mIndicatorTxtPaint.setTextSize(mScaleTextsize);

    mIndicatorViewPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mIndicatorViewPaint.setColor(Color.WHITE);

    mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mValuePaint.setColor(valueColor);
    mValuePaint.setStrokeWidth(mHighLineWidth);
    mValuePaint.setTextSize(mValueTextsize);

    mDanweiPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDanweiPaint.setColor(Color.DKGRAY);
    mDanweiPaint.setStrokeWidth(mHighLineWidth);
    mDanweiPaint.setTextSize(18);
}
 
Example 10
Project: PlusGram   File: MapPlaceholderDrawable.java   View Source Code Vote up 5 votes
public MapPlaceholderDrawable() {
    super();
    paint = new Paint();
    paint.setColor(0xffded7d6);
    linePaint = new Paint();
    linePaint.setColor(0xffc6bfbe);
    linePaint.setStrokeWidth(AndroidUtilities.dp(1));
}
 
Example 11
Project: TestChat   File: CircleLoadView.java   View Source Code Vote up 5 votes
private void init() {
        setBackgroundColor(Color.TRANSPARENT);
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(Color.WHITE);
        paddingSize = PixelUtil.dp2px(3);
        mPaint.setStrokeWidth(paddingSize);
        bgPaint = new Paint();
        bgPaint.setAntiAlias(true);
        bgPaint.setStyle(Paint.Style.FILL);
        bgPaint.setColor(Color.WHITE);
}
 
Example 12
Project: WithYou   File: OnlineFace.java   View Source Code Vote up 5 votes
private void detect(JSONObject obj) throws JSONException {
	int ret = obj.getInt("ret");
	if (ret != 0) {
		showTip("���ʧ��");
		return;
	}

	if ("success".equals(obj.get("rst"))) {
		JSONArray faceArray = obj.getJSONArray("face");

		Paint paint = new Paint();
		paint.setColor(Color.RED);
		paint.setStrokeWidth(Math.max(mImage.getWidth(), mImage.getHeight()) / 100f);

		Bitmap bitmap = Bitmap.createBitmap(mImage.getWidth(),
				mImage.getHeight(), Config.ARGB_8888);
		Canvas canvas = new Canvas(bitmap);
		canvas.drawBitmap(mImage, new Matrix(), null);
		for (int i = 0; i < faceArray.length(); i++) {
			float x1 = (float) faceArray.getJSONObject(i)
					.getJSONObject("position").getDouble("left");
			float y1 = (float) faceArray.getJSONObject(i)
					.getJSONObject("position").getDouble("top");
			float x2 = (float) faceArray.getJSONObject(i)
					.getJSONObject("position").getDouble("right");
			float y2 = (float) faceArray.getJSONObject(i)
					.getJSONObject("position").getDouble("bottom");
			paint.setStyle(Style.STROKE);
			canvas.drawRect(new Rect((int)x1, (int)y1, (int)x2, (int)y2), 
					paint);
		}

		mImage = bitmap;
		((ImageView) findViewById(R.id.online_img)).setImageBitmap(mImage);
	} else {
		showTip("���ʧ��");
	}
}
 
Example 13
Project: GitHub   File: WheelListView.java   View Source Code Vote up 5 votes
private void init(LineConfig config) {
    bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    bgPaint.setColor(Color.TRANSPARENT);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStrokeWidth(config.getThick());
    paint.setColor(config.getColor());
    paint.setAlpha(config.getAlpha());
}
 
Example 14
Project: Android-LineChart   File: LineChartView.java   View Source Code Vote up 5 votes
private void setupView() {
    linePaint = new Paint();
    linePaint.setAntiAlias(true);//抗锯齿
    linePaint.setStyle(Paint.Style.STROKE);//STROKE描边FILL填充
    linePaint.setColor(lineColor);
    linePaint.setStrokeWidth(dip2px(lineWidthDP));//边框宽度

    pointPaint = new Paint();
    pointPaint.setAntiAlias(true);
    pointPaint.setStyle(Paint.Style.FILL);
    pointPaint.setColor(pointColor);
    pointPaint.setStrokeWidth(dip2px(pointWidthDP));

    tablePaint = new Paint();
    tablePaint.setAntiAlias(true);
    tablePaint.setStyle(Paint.Style.STROKE);
    tablePaint.setColor(tableColor);
    tablePaint.setStrokeWidth(dip2px(tableWidthDP));

    textRulerPaint = new Paint();
    textRulerPaint.setAntiAlias(true);
    textRulerPaint.setStyle(Paint.Style.FILL);
    textRulerPaint.setTextAlign(Paint.Align.CENTER);
    textRulerPaint.setColor(rulerTextColor);//文本颜色
    textRulerPaint.setTextSize(sp2px(rulerTextSizeSP));//字体大小

    textPointPaint = new Paint();
    textPointPaint.setAntiAlias(true);
    textPointPaint.setStyle(Paint.Style.FILL);
    textPointPaint.setTextAlign(Paint.Align.CENTER);
    textPointPaint.setColor(pointTextColor);//文本颜色
    textPointPaint.setTextSize(sp2px(pointTextSizeSP));//字体大小

    linePath = new Path();
    tablePath = new Path();

    resetParam();
}
 
Example 15
Project: GitHub   File: HoloCircularProgressBar.java   View Source Code Vote up 5 votes
/**
 * updates the paint of the marker
 */
private void updateMarkerColor() {
    mMarkerColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mMarkerColorPaint.setColor(mProgressBackgroundColor);
    mMarkerColorPaint.setStyle(Paint.Style.STROKE);
    mMarkerColorPaint.setStrokeWidth(mCircleStrokeWidth / 2);

    invalidate();
}
 
Example 16
Project: RLibrary   File: RDownloadView.java   View Source Code Vote up 5 votes
private void initView(Context context) {
        normalDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_download);
        finishDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_yixiazai);
        if (isInEditMode()) {
            SkinHelper.init(context);
        } else {
            finishDrawable.mutate().setColorFilter(SkinHelper.getSkin().getThemeSubColor(), PorterDuff.Mode.MULTIPLY);
        }

        normalDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());
        finishDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mStrokeWidth = 2 * getResources().getDisplayMetrics().density;
        mPaint.setStrokeWidth(mStrokeWidth);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);//设置笔触的模式
//        mPaint.setStrokeJoin(Paint.Join.ROUND);//设置连接模式, 在绘制矩形各个角的时候有效果

        oval = new RectF();
    }
 
Example 17
Project: Multi-SwipeToRefreshLayout   File: BallClipRotatePulseIndicator.java   View Source Code Vote up 5 votes
@Override
public void draw(Canvas canvas, Paint paint) {
    float circleSpacing=12;
    float x=getWidth()/2;
    float y=getHeight()/2;

    //draw fill circle
    canvas.save();
    canvas.translate(x, y);
    canvas.scale(scaleFloat1, scaleFloat1);
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(0, 0, x / 2.5f, paint);

    canvas.restore();

    canvas.translate(x, y);
    canvas.scale(scaleFloat2, scaleFloat2);
    canvas.rotate(degrees);

    paint.setStrokeWidth(3);
    paint.setStyle(Paint.Style.STROKE);

    //draw two arc
    float[] startAngles=new float[]{225,45};
    for (int i = 0; i < 2; i++) {
        RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
        canvas.drawArc(rectF, startAngles[i], 90, false, paint);
    }
}
 
Example 18
Project: CSVideo   File: StartRecordingView.java   View Source Code Vote up 5 votes
private void intData() {
    circleLength1 = dip2px(40);
    circleLength2 = (dip2px(40) - 30);
    handler = new Handler();
    mPaint1 = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint3 = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint1.setColor(0xFFDDDDDD);
    mPaint2.setColor(0xFFFFFFFF);
    mPaint3.setStrokeWidth(10);
    mPaint3.setColor(0xFF64C166);
    mPaint3.setStyle(Paint.Style.STROKE);
}
 
Example 19
Project: AndroidButtonLib   File: RecyclerViewItemDecoration.java   View Source Code Vote up 4 votes
private void initPaint() {
    paint = new Paint();
    paint.setColor(color);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(thick);
}
 
Example 20
Project: xwallet   File: CircleLayout.java   View Source Code Vote up 4 votes
@SuppressLint("NewApi")
public CircleLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleLayout, 0, 0);

    Resources res = getResources();

    try {
        int dividerColor = a.getColor(R.styleable.CircleLayout_sliceDivider, res.getColor(android.R.color.transparent));
        mInnerCircle = a.getDrawable(R.styleable.CircleLayout_innerCircle);

        if(mInnerCircle instanceof ColorDrawable) {
            int innerColor = a.getColor(R.styleable.CircleLayout_innerCircle, res.getColor(android.R.color.white));
            mCirclePaint.setColor(innerColor);
        }

        mDividerPaint.setColor(dividerColor);

        mAngleOffset = a.getFloat(R.styleable.CircleLayout_angleOffset, 90f);
        mAngleRange = a.getFloat(R.styleable.CircleLayout_angleRange, 360f);
        mDividerWidth = a.getDimensionPixelSize(R.styleable.CircleLayout_dividerWidth, 1);
        mInnerRadius = a.getDimensionPixelSize(R.styleable.CircleLayout_innerRadius, 80);

        mLayoutMode = a.getColor(R.styleable.CircleLayout_layoutMode, LAYOUT_PIE);
    } finally {
        a.recycle();
    }

    mDividerPaint.setStrokeWidth(mDividerWidth);

    mXfer = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    mXferPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    //Turn off hardware acceleration if possible
    if(Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}