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

The following are Jave code examples for showing how to use setStyle() 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: GitHub   File: ColorsActivity.java   View Source Code Vote up 6 votes
public ColorView(Context context, int resourceLabel, boolean square) {
	super(context);

	mSquare = square;
	mResourceLabel = resourceLabel;

	mNumberFormatter = NumberFormat.getIntegerInstance(getContext().getResources().getConfiguration().locale);

	DisplayMetrics metrics = context.getResources().getDisplayMetrics();

	mTextPaint = new Paint();
	mTextPaint.setAntiAlias(true);
	mTextPaint.setTextSize((int) (metrics.density * FONT_SIZE_DP + 0.5f));
	mTextPaint.setColor(0xFFFFFFFF);
	mTextPaint.setTextAlign(Paint.Align.CENTER);

	mShadowPaint = new Paint(mTextPaint);
	mShadowPaint.setStyle(Paint.Style.STROKE);
	mShadowPaint.setStrokeCap(Paint.Cap.ROUND);
	mShadowPaint.setStrokeJoin(Paint.Join.ROUND);
	mShadowPaint.setStrokeWidth(4f);
	mShadowPaint.setColor(0xFF000000);

	int marginPx = (int) (MARGIN_DP * metrics.density + 0.5f);
	setPadding(marginPx, marginPx, marginPx, marginPx);
}
 
Example 2
Project: FlexibleRichTextView   File: CharBox.java   View Source Code Vote up 6 votes
public void draw(Canvas g2, float x, float y) {
	drawDebug(g2, x, y);
	g2.save();
	g2.translate(x, y);
	Typeface font = FontInfo.getFont(cf.fontId);
	if (size != 1) {
		g2.scale(size, size);
	}
	Paint st = AjLatexMath.getPaint();
	st.setTextSize(TeXFormula.PIXELS_PER_POINT);
	st.setTypeface(font);
	st.setStyle(Style.FILL);
	st.setAntiAlias(true);
	st.setStrokeWidth(0);
	arr[0] = cf.c;
	g2.drawText(arr, 0, 1, 0, 0, st);
	g2.restore();
}
 
Example 3
Project: Hello-Music-droid   File: PlayPauseButton.java   View Source Code Vote up 5 votes
/**
 * Paintの初期化
 */
private void setUpPaint() {
    mPaint = new Paint();
    mPaint.setColor(mBackgroundColor);
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);
}
 
Example 4
Project: AnnularMenuView   File: ShadowImageView.java   View Source Code Vote up 5 votes
private Bitmap createShadowBitmap(int shadowWidth, int shadowHeight, float shadowRadius, float shadowOffsetX, float shadowOffsetY, int fillColor) {
    Bitmap bitmap = Bitmap.createBitmap(shadowWidth, shadowHeight, Bitmap.Config.ALPHA_8);
    Canvas canvas = new Canvas(bitmap);
    RectF shadowRect = new RectF(shadowRadius, shadowRadius, shadowWidth - shadowRadius, shadowHeight - shadowRadius);
    if (shadowOffsetX > 0) {
        shadowRect.left += shadowOffsetX;
        shadowRect.right -= shadowOffsetX;
    } else if (shadowOffsetX < 0) {
        shadowRect.left += Math.abs(shadowOffsetX);
        shadowRect.right -= Math.abs(shadowOffsetX);
    }

    if (shadowOffsetY > 0) {
        shadowRect.top += shadowOffsetY;
        shadowRect.bottom -= shadowOffsetY;
    } else if (shadowOffsetY < 0) {
        shadowRect.top += Math.abs(shadowOffsetY);
        shadowRect.bottom -= Math.abs(shadowOffsetY);
    }

    Paint shadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    shadowPaint.setColor(Color.parseColor(DEFAULT_SHADOW_COLOR));
    shadowPaint.setStyle(Paint.Style.FILL);
    shadowPaint.setShadowLayer(shadowRadius, shadowOffsetX, shadowOffsetY, Color.parseColor(DEFAULT_SHADOW_COLOR));
    int radius = Math.max(mImageView.getMeasuredWidth(), mImageView.getMeasuredHeight());
    canvas.drawRoundRect(shadowRect, radius, radius, shadowPaint);

    return bitmap;
}
 
Example 5
Project: Android-SwitchIcon   File: SwitchIconView.java   View Source Code Vote up 5 votes
public SwitchIconView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  TypedArray array = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.SwitchIconView, 0, 0);

  try {
    iconTintColor = array.getColor(R.styleable.SwitchIconView_si_tint_color, Color.BLACK);
    animationDuration = array.getInteger(R.styleable.SwitchIconView_si_animation_duration, DEFAULT_ANIMATION_DURATION);
    disabledStateAlpha = array.getFloat(R.styleable.SwitchIconView_si_disabled_alpha, DEFAULT_DISABLED_ALPHA);
    disabledStateColor = array.getColor(R.styleable.SwitchIconView_si_disabled_color, iconTintColor);
    enabled = array.getBoolean(R.styleable.SwitchIconView_si_enabled, true);
    noDash = array.getBoolean(R.styleable.SwitchIconView_si_no_dash, false);
  } finally {
    array.recycle();
  }

  if (disabledStateAlpha < 0f || disabledStateAlpha > 1f) {
    throw new IllegalArgumentException("Wrong value for si_disabled_alpha [" + disabledStateAlpha + "]. "
        + "Must be value from range [0, 1]");
  }

  colorFilter = new PorterDuffColorFilter(iconTintColor, PorterDuff.Mode.SRC_IN);
  setColorFilter(colorFilter);

  dashXStart = getPaddingLeft();
  dashYStart = getPaddingTop();

  dashPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
  dashPaint.setStyle(Paint.Style.STROKE);
  dashPaint.setColor(iconTintColor);

  clipPath = new Path();

  initDashCoordinates();
  setFraction(enabled ? 0f : 1f);
}
 
Example 6
Project: WxPlane   File: MySurface.java   View Source Code Vote up 5 votes
public void init(Context context, AttributeSet attrs){

        holder=getHolder();
        holder.addCallback(this);
        p=new Paint();
        p.setStrokeWidth(1);

        bgp=new Paint();
        bgp.setAntiAlias(true);
        bgp.setStyle(Paint.Style.STROKE);
        bgp.setStrokeWidth(1);

        scorep=new Paint();
        scorep.setColor(Color.parseColor("#996633"));
        scorep.setTextSize(50);
        scorep.setStrokeWidth(10);
        bmyp= BitmapFactory.decodeResource(getResources(), R.drawable.plane);
        bbullet= BitmapFactory.decodeResource(getResources(), R.drawable.bullet);
        botherp= BitmapFactory.decodeResource(getResources(), R.drawable.small);
        Bitmap tmp= BitmapFactory.decodeResource(getResources(), R.drawable.middle);
        otherpbit=new Bitmap[]{botherp,tmp};

        Bitmap tmp1=BitmapFactory.decodeResource(getResources(), R.drawable.bomb1);
        Bitmap tmp2=BitmapFactory.decodeResource(getResources(), R.drawable.bomb2);

        bomb=new Bitmap[]{tmp1,tmp2};
        fire=new int[]{2000,5000};
        SoundPool.Builder sb= new SoundPool.Builder();
        sb.setMaxStreams(2);
        sp=sb.build();
        shootID=sp.load(getContext(),R.raw.shoot,1);
        bombID=sp.load(getContext(),R.raw.explosion,1);
        overID=sp.load(getContext(),R.raw.over,1);
    }
 
Example 7
Project: buildAPKsApps   File: ScatterChart.java   View Source Code Vote up 5 votes
/**
 * The graphical representation of the legend shape.
 * 
 * @param canvas the canvas to paint to
 * @param renderer the series renderer
 * @param x the x value of the point the shape should be drawn at
 * @param y the y value of the point the shape should be drawn at
 * @param seriesIndex the series index
 * @param paint the paint to be used for drawing
 */
public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
    int seriesIndex, Paint paint) {
  if (((XYSeriesRenderer) renderer).isFillPoints()) {
    paint.setStyle(Style.FILL);
  } else {
    paint.setStyle(Style.STROKE);
  }
  switch (((XYSeriesRenderer) renderer).getPointStyle()) {
  case X:
    drawX(canvas, paint, x + SHAPE_WIDTH, y);
    break;
  case CIRCLE:
    drawCircle(canvas, paint, x + SHAPE_WIDTH, y);
    break;
  case TRIANGLE:
    drawTriangle(canvas, paint, new float[6], x + SHAPE_WIDTH, y);
    break;
  case SQUARE:
    drawSquare(canvas, paint, x + SHAPE_WIDTH, y);
    break;
  case DIAMOND:
    drawDiamond(canvas, paint, new float[8], x + SHAPE_WIDTH, y);
    break;
  case POINT:
    canvas.drawPoint(x + SHAPE_WIDTH, y, paint);
    break;
  }
}
 
Example 8
Project: SRecyclerView   File: BallClipRotateIndicator.java   View Source Code Vote up 5 votes
@Override
public void draw(Canvas canvas, Paint paint) {
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(3);

    float circleSpacing=12;
    float x = (getWidth()) / 2;
    float y=(getHeight()) / 2;
    canvas.translate(x, y);
    canvas.scale(scaleFloat, scaleFloat);
    canvas.rotate(degrees);
    RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,0+x-circleSpacing,0+y-circleSpacing);
    canvas.drawArc(rectF, -45, 270, false, paint);
}
 
Example 9
Project: VanGogh   File: CheckView.java   View Source Code Vote up 5 votes
private void init(Context context) {
    mDensity = context.getResources().getDisplayMetrics().density;

    mStrokePaint = new Paint();
    mStrokePaint.setAntiAlias(true);
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
    mStrokePaint.setStrokeWidth(STROKE_WIDTH * mDensity);
    mStrokePaint.setColor(Color.WHITE);

    mCheckDrawable = ResourcesCompat.getDrawable(context.getResources(),
            R.drawable.van_check_white_18dp, context.getTheme());
}
 
Example 10
Project: style-transfer   File: DrawView.java   View Source Code Vote up 5 votes
private void setup(Context context) {
    mPaint1 = new Paint();
    mPaint2 = new Paint();
    mPaint1.setStyle(Paint.Style.STROKE);
    mPaint1.setColor(Color.BLACK);
    mPaint1.setStrokeWidth(2);
    mPaint2.setStyle(Paint.Style.STROKE);
    mPaint2.setColor(Color.YELLOW);
}
 
Example 11
Project: BezierView   File: BezierMoveView.java   View Source Code Vote up 5 votes
/**
 * 进行初始化的一些操作
 */
private void init(Context context) {

    //设置各点的位置
    mStartXPoint = 100;
    mStartYPoint = 100;
    mEndXPoint = 600;
    mEndYPoint = 600;
    mConXPoint = 400;
    mConYPoint = 0;
    mMoveXPoint = 100;
    mMoveYPoint = 100;

    //路径,画笔设置
    mPath = new Path();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.BLUE);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(8);

    mCircleRadius = 20;
    mCirlcePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCirlcePaint.setColor(Color.BLUE);
    mCirlcePaint.setStyle(Paint.Style.FILL);

    setOnClickListener(this);


}
 
Example 12
Project: androidthings-kuman-sm9   File: OledDisplayHelper.java   View Source Code Vote up 5 votes
@Inject
public OledDisplayHelper(Application application,
                         SystemHelper systemHelper,
                         SensorDriverController sensorDriverController) {
    mSystemHelper = systemHelper;
    mSensorDriverController = sensorDriverController;
    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextSize(TEXT_SIZE);
    mTextPaint.setTypeface(ResourcesCompat.getFont(application, R.font.oled_font));
    mTextPaint.setColor(Color.BLACK);
    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.WHITE);
    mBackgroundPaint.setStyle(Paint.Style.FILL);
    mNetworkInterfaceAddressList = new ArrayList<>(4);
}
 
Example 13
Project: PlusGram   File: ShutterButton.java   View Source Code Vote up 5 votes
public ShutterButton(Context context) {
    super(context);
    shadowDrawable = getResources().getDrawable(R.drawable.camera_btn);
    whitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    whitePaint.setStyle(Paint.Style.FILL);
    whitePaint.setColor(0xffffffff);
    redPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    redPaint.setStyle(Paint.Style.FILL);
    redPaint.setColor(0xffcd4747);
    state = State.DEFAULT;
}
 
Example 14
Project: UIWidget   File: MaterialProgressBar.java   View Source Code Vote up 5 votes
private void init() {
    arcPaint = new Paint();
    arcPaint.setColor(arcColor);
    arcPaint.setStrokeWidth(borderWidth);
    arcPaint.setAntiAlias(true);
    arcPaint.setStyle(Paint.Style.STROKE);
    arcRect = new RectF();
}
 
Example 15
Project: ParsingPlayer   File: VerticalProgressBar.java   View Source Code Vote up 5 votes
private void initView() {
    mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressPaint.setColor(mProgressColor);
    mBackgroundPaint.setColor(mBackgroundColor);
    mProgressPaint.setStrokeWidth(10);
    mProgressPaint.setStyle(Paint.Style.FILL);
    mBackgroundPaint.setStrokeWidth(10);
    mBackgroundPaint.setStyle(Paint.Style.FILL);
}
 
Example 16
Project: android_ui   File: CircularProgressDrawable.java   View Source Code Vote up 4 votes
/**
 */
@Override
protected void onDrawBackground(@NonNull Canvas canvas, @NonNull Paint paint, @Nullable ColorFilter colorFilter) {
	paint.setStyle(Paint.Style.STROKE);
	canvas.drawArc(OVAL, 0, MAX_ANGLE, false, paint);
}
 
Example 17
Project: MISportsConnectWidget   File: MISportsConnectView.java   View Source Code Vote up 4 votes
private void init(Context context) {
    mainTitlePaint = new Paint();
    mainTitlePaint.setColor(ContextCompat.getColor(context, R.color.white));
    mainTitlePaint.setTextAlign(Paint.Align.CENTER);
    mainTitlePaint.setTextSize(DensityUtils.sp2px(context, MAIN_TITLE_FONT_SIZE_SP));
    mainTitleOffsetY = -(mainTitlePaint.getFontMetrics().ascent +
            mainTitlePaint.getFontMetrics().descent) / 2;
    mainTitlePaint.setAntiAlias(true);

    circleColor = ContextCompat.getColor(context, R.color.whiteTransparent);
    subTitlePaint = new Paint();
    subTitlePaint.setColor(circleColor);
    subTitlePaint.setTextSize(DensityUtils.sp2px(context, SUB_TITLE_FONT_SIZE_SP));
    subTitleOffsetY = DensityUtils.sp2px(context, SUB_TITLE_FONT_OFFSET_DP);
    subTitleSeparator = getResources().getString(R.string.sub_title_separator);
    subTitlePaint.setAntiAlias(true);

    bigCirclePaint = new Paint();
    bigCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, BIG_CIRCLE_SIZE));
    bigCirclePaint.setStyle(Paint.Style.STROKE);
    bigCirclePaint.setAntiAlias(true);

    blurPaint = new Paint(bigCirclePaint);
    blurSize = DensityUtils.dp2px(context, CIRCLE_BLUR_SIZE);

    PathEffect pathEffect1 = new CornerPathEffect(DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_RADIUS));
    PathEffect pathEffect2 = new DiscretePathEffect(DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_RADIUS),
            DensityUtils.dp2px(getContext(), BIG_CIRCLE_SHAKE_OFFSET));
    PathEffect pathEffect = new ComposePathEffect(pathEffect1, pathEffect2);
    bigCirclePaint.setPathEffect(pathEffect);

    dottedCirclePaint = new Paint();
    dottedCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, DOTTED_CIRCLE_WIDTH));
    dottedCirclePaint.setColor(ContextCompat.getColor(context, R.color.whiteTransparent));
    dottedCirclePaint.setStyle(Paint.Style.STROKE);
    float gagPx = DensityUtils.dp2px(context, DOTTED_CIRCLE_GAG);
    dottedCirclePaint.setPathEffect(new DashPathEffect(new float[]{gagPx, gagPx}, 0));
    dottedCirclePaint.setAntiAlias(true);

    solidCirclePaint = new Paint();
    solidCirclePaint.setStrokeWidth(DensityUtils.dp2px(context, SOLID_CIRCLE_WIDTH));
    solidCirclePaint.setColor(ContextCompat.getColor(context, R.color.white));
    solidCirclePaint.setStyle(Paint.Style.STROKE);
    solidCirclePaint.setStrokeCap(Paint.Cap.ROUND);
    solidCirclePaint.setAntiAlias(true);

    dotPaint = new Paint();
    dotPaint.setStrokeWidth(DensityUtils.dp2px(context, DOT_SIZE));
    dotPaint.setStrokeCap(Paint.Cap.ROUND);
    dotPaint.setColor(ContextCompat.getColor(context, R.color.white));
    dotPaint.setAntiAlias(true);

    backgroundBitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.bg_step_law);

    // 设置手表 icon 的大小
    watchBitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.icon_headview_watch);
    float scale = DensityUtils.dp2px(context, WATCH_SIZE) / watchBitmap.getWidth();
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);
    watchBitmap = Bitmap.createBitmap(watchBitmap,
            0, 0, watchBitmap.getWidth(), watchBitmap.getHeight(),
            matrix, true);
    watchOffset = DensityUtils.sp2px(context, WATCH_OFFSET_DP);

    fireworksCircle = new FireworksCircleGraphics(context);

    animationThread = new AnimationThread();
    animationThread.start();
}
 
Example 18
Project: Building-Android-UIs-with-Custom-Views   File: OwnCustomView.java   View Source Code Vote up 4 votes
private void init() {
    backgroundPaint = new Paint();
    backgroundPaint.setStyle(Paint.Style.FILL);
}
 
Example 19
Project: Rxjava2.0Demo   File: PathsDrawable.java   View Source Code Vote up 4 votes
public PathsDrawable() {
    mPaint = new Paint();
    mPaint.setColor(0xff11bbff);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setAntiAlias(true);
}
 
Example 20
Project: Supreme   File: PieChartView.java   View Source Code Vote up 4 votes
private void initPaint() {
    paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
}