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


Java Paint.setStyle方法代碼示例

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


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

示例1: ColorView

import android.graphics.Paint; //導入方法依賴的package包/類
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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:ColorsActivity.java

示例2: draw

import android.graphics.Paint; //導入方法依賴的package包/類
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();
}
 
開發者ID:daquexian,項目名稱:FlexibleRichTextView,代碼行數:19,代碼來源:CharBox.java

示例3: SwitchIconView

import android.graphics.Paint; //導入方法依賴的package包/類
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);
}
 
開發者ID:zagum,項目名稱:Android-SwitchIcon,代碼行數:37,代碼來源:SwitchIconView.java

示例4: setUpPaint

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Paintの初期化
 */
private void setUpPaint() {
    mPaint = new Paint();
    mPaint.setColor(mBackgroundColor);
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:10,代碼來源:PlayPauseButton.java

示例5: createShadowBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
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;
}
 
開發者ID:DingMouRen,項目名稱:AnnularMenuView,代碼行數:30,代碼來源:ShadowImageView.java

示例6: init

import android.graphics.Paint; //導入方法依賴的package包/類
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);
    }
 
開發者ID:dingdangmao123,項目名稱:WxPlane,代碼行數:35,代碼來源:MySurface.java

示例7: drawLegendShape

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 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;
  }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:39,代碼來源:ScatterChart.java

示例8: draw

import android.graphics.Paint; //導入方法依賴的package包/類
@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);
}
 
開發者ID:magicbaby810,項目名稱:SRecyclerView,代碼行數:15,代碼來源:BallClipRotateIndicator.java

示例9: init

import android.graphics.Paint; //導入方法依賴的package包/類
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());
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:14,代碼來源:CheckView.java

示例10: setup

import android.graphics.Paint; //導入方法依賴的package包/類
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);
}
 
開發者ID:googlecodelabs,項目名稱:style-transfer,代碼行數:10,代碼來源:DrawView.java

示例11: init

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 進行初始化的一些操作
 */
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);


}
 
開發者ID:Lichenwei-Dev,項目名稱:BezierView,代碼行數:32,代碼來源:BezierMoveView.java

示例12: OledDisplayHelper

import android.graphics.Paint; //導入方法依賴的package包/類
@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);
}
 
開發者ID:leinardi,項目名稱:androidthings-kuman-sm9,代碼行數:16,代碼來源:OledDisplayHelper.java

示例13: ShutterButton

import android.graphics.Paint; //導入方法依賴的package包/類
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;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:12,代碼來源:ShutterButton.java

示例14: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init() {
    arcPaint = new Paint();
    arcPaint.setColor(arcColor);
    arcPaint.setStrokeWidth(borderWidth);
    arcPaint.setAntiAlias(true);
    arcPaint.setStyle(Paint.Style.STROKE);
    arcRect = new RectF();
}
 
開發者ID:AriesHoo,項目名稱:UIWidget,代碼行數:9,代碼來源:MaterialProgressBar.java

示例15: initView

import android.graphics.Paint; //導入方法依賴的package包/類
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);
}
 
開發者ID:TedaLIEz,項目名稱:ParsingPlayer,代碼行數:11,代碼來源:VerticalProgressBar.java


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