本文整理汇总了Java中android.graphics.Paint.setPathEffect方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setPathEffect方法的具体用法?Java Paint.setPathEffect怎么用?Java Paint.setPathEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.setPathEffect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DvbParser
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Construct an instance for the given subtitle and ancillary page ids.
*
* @param subtitlePageId The id of the subtitle page carrying the subtitle to be parsed.
* @param ancillaryPageId The id of the ancillary page containing additional data.
*/
public DvbParser(int subtitlePageId, int ancillaryPageId) {
defaultPaint = new Paint();
defaultPaint.setStyle(Paint.Style.FILL_AND_STROKE);
defaultPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
defaultPaint.setPathEffect(null);
fillRegionPaint = new Paint();
fillRegionPaint.setStyle(Paint.Style.FILL);
fillRegionPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OVER));
fillRegionPaint.setPathEffect(null);
canvas = new Canvas();
defaultDisplayDefinition = new DisplayDefinition(719, 575, 0, 719, 0, 575);
defaultClutDefinition = new ClutDefinition(0, generateDefault2BitClutEntries(),
generateDefault4BitClutEntries(), generateDefault8BitClutEntries());
subtitleService = new SubtitleService(subtitlePageId, ancillaryPageId);
}
示例2: onDraw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
int d = DensityUtil.dp2px(5);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0x44ffffff);
paint.setStrokeWidth(DensityUtil.dp2px(1));
paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
TextView textView = new TextView(getContext());
textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表下拉Header的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
textView.setTextColor(0x44ffffff);
textView.setGravity(Gravity.CENTER);
textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
textView.layout(0, 0, getWidth(), getHeight());
textView.draw(canvas);
}
}
示例3: onCreate
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_recyclerview);
// Workaround for dash path effect
// https://code.google.com/p/android/issues/detail?id=29944
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
recyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
SimpleAdapter adapter = new SimpleAdapter(this);
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(OrientationHelper.VERTICAL);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(adapter);
Paint paint = new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)
.paint(paint)
.showLastDivider()
.build());
}
示例4: drawVerticalLine
import android.graphics.Paint; //导入方法依赖的package包/类
private void drawVerticalLine(Canvas canvas, int position, int percent) {
float x = getX(position);
float y = getY(percent);
Paint paint = new Paint();
paint.setColor(colorEnd);
paint.setStrokeWidth(DimensUtils.dpToPx(getContext(), 0.5f));
paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{lineDash, lineDash}, 0));
canvas.drawLine(x, y + radius * 2, x, getY(0), paint);
}
示例5: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init(){
calculateDelta();
bgpaint=new Paint();
bgpaint.setAntiAlias(true);//抗锯齿功能
bgpaint.setColor(bgclolor); //设置画笔颜色
bgpaint.setStyle(Paint.Style.FILL);//设置填充样式 Style.FILL/Style.FILL_AND_STROKE/Style.STROKE
setLayerType( LAYER_TYPE_SOFTWARE , null);
outpaint = new Paint();
outpaint.setAntiAlias(true);
outpaint.setStyle(Paint.Style.STROKE);
outpaint.setStrokeWidth(internalStrokeWidth);
if(dash) {
outpaint.setPathEffect(new DashPathEffect(new float[]{uit, dashSpace},
0));
}else{
//设置线冒,这个并非不管用,而是他的颜色未达到预期
// outpaint.setStrokeJoin(Paint.Join.ROUND);
// outpaint.setStrokeCap(Paint.Cap.ROUND);
//伪装的线冒哈哈
startPaint = new Paint();
startPaint.setColor(unitstartcolor);
startPaint.setAntiAlias(true);
startPaint.setStyle(Paint.Style.FILL);
endPaint = new Paint();
endPaint.setAntiAlias(true);
endPaint.setStyle(Paint.Style.FILL);
}
}
示例6: initView
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Inits paint objects and default values.
*/
private void initView() {
starPath = new Path();
cornerPathEffect = new CornerPathEffect(starCornerRadius);
paintStarOutline = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
paintStarOutline.setStyle(Paint.Style.FILL_AND_STROKE);
paintStarOutline.setAntiAlias(true);
paintStarOutline.setDither(true);
paintStarOutline.setStrokeJoin(Paint.Join.ROUND);
paintStarOutline.setStrokeCap(Paint.Cap.ROUND);
paintStarOutline.setColor(Color.BLACK);
paintStarOutline.setPathEffect(cornerPathEffect);
paintStarBorder = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
paintStarBorder.setStyle(Paint.Style.STROKE);
paintStarBorder.setStrokeJoin(Paint.Join.ROUND);
paintStarBorder.setStrokeCap(Paint.Cap.ROUND);
paintStarBorder.setStrokeWidth(starBorderWidth);
paintStarBorder.setPathEffect(cornerPathEffect);
paintStarBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
paintStarBackground.setStyle(Paint.Style.FILL_AND_STROKE);
paintStarBackground.setAntiAlias(true);
paintStarBackground.setDither(true);
paintStarBackground.setStrokeJoin(Paint.Join.ROUND);
paintStarBackground.setStrokeCap(Paint.Cap.ROUND);
paintStarFill = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
paintStarFill.setStyle(Paint.Style.FILL_AND_STROKE);
paintStarFill.setAntiAlias(true);
paintStarFill.setDither(true);
paintStarFill.setStrokeJoin(Paint.Join.ROUND);
paintStarFill.setStrokeCap(Paint.Cap.ROUND);
defaultStarSize = applyDimension(COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
}
示例7: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
DashPathEffect mPathEffect = new DashPathEffect(new float[]{dp2px(2), dp2px(2)}, 1);
mGradeAxisPaint = new Paint();
mGradeAxisPaint.reset();
mGradeAxisPaint.setStyle(Paint.Style.STROKE);
mGradeAxisPaint.setStrokeWidth(1);
mGradeAxisPaint.setColor(isDebug ? Color.parseColor("#000000") : Color.parseColor("#16ffffff"));
mGradeAxisPaint.setAntiAlias(true);
mGradeAxisPaint.setPathEffect(mPathEffect);
mTextPaint = new TextPaint();
mTextPaint.setColor(Color.parseColor("#ffffff"));
mTextPaint.setTextSize(dp2px(11));
mTextPaint.setAntiAlias(true);
}
示例8: initData
import android.graphics.Paint; //导入方法依赖的package包/类
private void initData() {
float defaultLineStrokeWidth = getResources().getDimension(R.dimen.stpi_default_line_stroke_width);
linePaint = new Paint();
linePaint.setStrokeWidth(defaultLineStrokeWidth);
linePaint.setStrokeCap(Paint.Cap.ROUND);
linePaint.setStyle(Paint.Style.STROKE);
linePaint.setColor(Color.parseColor("#b3bdc2"));
linePaint.setAntiAlias(true);
lineDoneAnimatedPaint = new Paint(linePaint);
lineDoneAnimatedPaint.setColor(Color.parseColor("#00b47c"));
lineDoneAnimatedPaint.setPathEffect(null);
}
示例9: AlertDrawable
import android.graphics.Paint; //导入方法依赖的package包/类
public AlertDrawable(int outerCircleRadiusDP, int textSizeSP, int cornerArc, String drawText, Context context) {
mContext = context;
circleRadius = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_DIP, outerCircleRadiusDP);
textSize = ScreenUtils.unitToPixels(context, TypedValue.COMPLEX_UNIT_SP, textSizeSP);
mDrawText = TextUtils.isEmpty(drawText) ? " " : drawText;
initBitmap(mDrawText);
mBackGroundPaint = new Paint();
mBackGroundPaint.setAntiAlias(true);
mBackGroundPaint.setDither(true);
mBackGroundPaint.setColor(Color.WHITE);
mBackGroundPaint.setStyle(Paint.Style.FILL);
mCircleFillPaint = new Paint();
mCircleFillPaint.setAntiAlias(true);
mCircleFillPaint.setDither(true);
mCircleFillPaint.setColor(ContextCompat.getColor(context, R.color.colorMultiArc));
mCircleFillPaint.setStyle(Paint.Style.FILL);
mOuterCircleFillPaint = new Paint();
mOuterCircleFillPaint.setAntiAlias(true);
mOuterCircleFillPaint.setDither(true);
mOuterCircleFillPaint.setColor(Color.WHITE);
mOuterCircleFillPaint.setStyle(Paint.Style.FILL);
mOuterCircleFillPaint.setTextSize(textSize);
borderPath = new Path();
borderRect = new Rect();
CornerPathEffect cornerPathEffect = new CornerPathEffect(cornerArc);
mBackGroundPaint.setPathEffect(cornerPathEffect);
outerCircleOffset = context.getResources().getInteger(R.integer.outerCircleOffset);
}
示例10: rainGraph
import android.graphics.Paint; //导入方法依赖的package包/类
private void rainGraph() {
LineChartView lineChartView = (LineChartView) findViewById(R.id.graph_rain);
// Data
LineSet dataset = new LineSet();
for (int i = 0; i < weatherList.size(); i++) {
float rain = Float.parseFloat(weatherList.get(i).getRain());
if (rain < minRain) {
minRain = rain;
}
if (rain > maxRain) {
maxRain = rain;
}
dataset.addPoint(getDateLabel(weatherList.get(i), i), rain);
}
dataset.setSmooth(false);
dataset.setColor(Color.parseColor("#2196F3"));
dataset.setThickness(4);
lineChartView.addData(dataset);
// Grid
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#333333"));
paint.setPathEffect(new DashPathEffect(new float[]{10, 10}, 0));
paint.setStrokeWidth(1);
lineChartView.setGrid(ChartView.GridType.HORIZONTAL, paint);
lineChartView.setBorderSpacing(Tools.fromDpToPx(10));
lineChartView.setAxisBorderValues((int) minRain - 1, (int) maxRain + 2);
lineChartView.setStep(1);
lineChartView.setXAxis(false);
lineChartView.setYAxis(false);
lineChartView.show();
}
示例11: init
import android.graphics.Paint; //导入方法依赖的package包/类
private void init() {
paintMarker = new Paint();
paintMarker.setColor(Color.RED);
paintMarker.setStrokeWidth(10);
paintMarker.setStyle(Paint.Style.STROKE);
// to create a discontinuous marker
paintMarker.setPathEffect(new DashPathEffect(new float[] {10,20}, 0));
Drawable drawable = new BitmapDrawable(getResources(), decodeResource(getResources(),
R.drawable.goku_supersayan));
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawableStore.put(KEY_BITMAP_HEAD, drawable);
rect = new Rect();
transformation = new Matrix();
}
示例12: Chart
import android.graphics.Paint; //导入方法依赖的package包/类
public Chart(Context context, AttributeSet attrs) {
super(context, attrs);
linePaint = new Paint();
linePaint.setAntiAlias(true);
linePaint.setColor(0xffffffff);
linePaint.setStrokeWidth(8.f);
linePaint.setStyle(Paint.Style.STROKE);
circlePaint = new Paint();
circlePaint.setAntiAlias(true);
circlePaint.setColor(0xffff2020);
circlePaint.setStyle(Paint.Style.FILL);
backgroundPaint = new Paint();
backgroundPaint.setColor(0xffFFFF80);
backgroundPaint.setStyle(Paint.Style.STROKE);
backgroundPaint.setPathEffect(new DashPathEffect(new float[] {5, 5}, 0));
backgroundPaint.setTextSize(20.f);
graphPath = new Path();
circlePath = new Path();
backgroundPath = new Path();
lastWidth = -1;
lastHeight = -1;
textBoundaries = new Rect();
decimalFormat = new DecimalFormat("#.##");
verticalLabels = new String[11];
invertVerticalAxis = false;
drawLegend = true;
}
示例13: drawBorder
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void drawBorder(XulDC dc, Rect rect, int xBase, int yBase) {
if (_isInvisible()) {
return;
}
Paint defStrokePaint = _ctx.getDefStrokePaint();
Rect targetRc = getDrawingRect();
if (_borderSize > 0.1f && (_borderColor & 0xFF000000) != 0) {
float borderSize = _borderSize * _scalarX;
defStrokePaint.setStrokeWidth(borderSize);
defStrokePaint.setColor(_borderColor);
if (_borderEffect != null) {
defStrokePaint.setPathEffect(_borderEffect);
}
if (_clipShape != null) {
RectF focusRect = this.getFocusRect();
Canvas canvas = dc.getCanvas();
_clipShape.resize(XulUtils.calRectWidth(focusRect), XulUtils.calRectHeight(focusRect));
_clipShape.draw(canvas, defStrokePaint);
} else if (_borderRoundX > 0.5 && _borderRoundY > 0.5) {
float borderDelta = (borderSize / 2) - borderSize * _borderPos;
float x = targetRc.left + borderDelta + _screenX + xBase;
float y = targetRc.top + borderDelta + _screenY + yBase;
float cx = XulUtils.calRectWidth(targetRc) - 2 * borderDelta;
float cy = XulUtils.calRectHeight(targetRc) - 2 * borderDelta;
dc.drawRoundRect(x, y, cx, cy, _borderRoundX * _scalarX, _borderRoundY * _scalarY, defStrokePaint);
} else {
int xStart = _screenX + xBase;
int yStart = _screenY + yBase;
dc.drawRect(targetRc.left + xStart, targetRc.top + yStart, targetRc.right + xStart, targetRc.bottom + yStart, defStrokePaint);
}
if (_borderEffect != null) {
defStrokePaint.setPathEffect(null);
}
}
}
示例14: onCreate
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loadmore);
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
ultimateRecyclerView.setHasFixedSize(false);
List<String> stringList = new ArrayList<>();
stringList.add("111");
stringList.add("aaa");
stringList.add("222");
stringList.add("33");
stringList.add("44");
stringList.add("55");
simpleRecyclerViewAdapter = new MultiViewTypesRecyclerViewAdapter(stringList);
simpleRecyclerViewAdapter.setCustomLoadMoreView(
LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
// stringList.add("66");
// stringList.add("11771");
linearLayoutManager = new LinearLayoutManager(this);
ultimateRecyclerView.setLayoutManager(linearLayoutManager);
// ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
simpleRecyclerViewAdapter.insert("Refresh things", 0);
ultimateRecyclerView.setRefreshing(false);
// ultimateRecyclerView.scrollBy(0, -50);
linearLayoutManager.scrollToPosition(0);
}
}, 1000);
}
});
Paint paint = new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
ultimateRecyclerView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
ultimateRecyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).paint(paint).build());
// simpleRecyclerViewAdapter.ad
}
示例15: WaveformView
import android.graphics.Paint; //导入方法依赖的package包/类
public WaveformView(Context context, AttributeSet attrs) {
super(context, attrs);
// We don't want keys, the markers get these
setFocusable(false);
mGridPaint = new Paint();
mGridPaint.setAntiAlias(false);
mGridPaint.setColor(
getResources().getColor(R.drawable.grid_line));
mSelectedLinePaint = new Paint();
mSelectedLinePaint.setAntiAlias(false);
mSelectedLinePaint.setColor(
getResources().getColor(R.drawable.waveform_selected));
mUnselectedLinePaint = new Paint();
mUnselectedLinePaint.setAntiAlias(false);
mUnselectedLinePaint.setColor(
getResources().getColor(R.drawable.waveform_unselected));
mUnselectedBkgndLinePaint = new Paint();
mUnselectedBkgndLinePaint.setAntiAlias(false);
mUnselectedBkgndLinePaint.setColor(
getResources().getColor(
R.drawable.waveform_unselected_bkgnd_overlay));
mBorderLinePaint = new Paint();
mBorderLinePaint.setAntiAlias(true);
mBorderLinePaint.setStrokeWidth(1.5f);
mBorderLinePaint.setPathEffect(
new DashPathEffect(new float[] { 3.0f, 2.0f }, 0.0f));
mBorderLinePaint.setColor(
getResources().getColor(R.drawable.selection_border));
mPlaybackLinePaint = new Paint();
mPlaybackLinePaint.setAntiAlias(false);
mPlaybackLinePaint.setColor(
getResources().getColor(R.drawable.playback_indicator));
mTimecodePaint = new Paint();
mTimecodePaint.setTextSize(12);
mTimecodePaint.setAntiAlias(true);
mTimecodePaint.setColor(
getResources().getColor(R.drawable.timecode));
mTimecodePaint.setShadowLayer(
2, 1, 1,
getResources().getColor(R.drawable.timecode_shadow));
mGestureDetector = new GestureDetector(
context,
new GestureDetector.SimpleOnGestureListener() {
public boolean onFling(
MotionEvent e1, MotionEvent e2, float vx, float vy) {
mListener.waveformFling(vx);
return true;
}
});
mSoundFile = null;
mLenByZoomLevel = null;
mValuesByZoomLevel = null;
mHeightsAtThisZoomLevel = null;
mOffset = 0;
mPlaybackPos = -1;
mSelectionStart = 0;
mSelectionEnd = 0;
mDensity = 1.0f;
mInitialized = false;
}