@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);
}
}
java类android.graphics.DashPathEffect的实例源码
FalsifyHeader.java 文件源码
项目:Rxjava2.0Demo
阅读 28
收藏 0
点赞 0
评论 0
FalsifyFooter.java 文件源码
项目:Rxjava2.0Demo
阅读 39
收藏 0
点赞 0
评论 0
@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运行时代表上拉Footer的高度【" + 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);
}
}
DashedLine.java 文件源码
项目:hypertrack-live-android
阅读 38
收藏 0
点赞 0
评论 0
public DashedLine(Context context, AttributeSet attrs) {
super(context, attrs);
int dashGap, dashLength, dashThickness;
int color;
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DashedLine, 0, 0);
try {
dashGap = a.getDimensionPixelSize(R.styleable.DashedLine_dashGap, 5);
dashLength = a.getDimensionPixelSize(R.styleable.DashedLine_dashLength, 5);
dashThickness = a.getDimensionPixelSize(R.styleable.DashedLine_dashThickness, 3);
color = a.getColor(R.styleable.DashedLine_color, 0xff000000);
orientation = a.getInt(R.styleable.DashedLine_orientation, ORIENTATION_HORIZONTAL);
} finally {
a.recycle();
}
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(dashThickness);
mPaint.setPathEffect(new DashPathEffect(new float[]{dashLength, dashGap,}, 0));
}
WXSvgPath.java 文件源码
项目:weex-svg
阅读 67
收藏 0
点赞 0
评论 0
/**
* Sets up paint according to the props set on a shadow view. Returns {@code true}
* if the stroke should be drawn, {@code false} if not.
*/
protected boolean setupStrokePaint(Paint paint, float opacity, @Nullable RectF box) {
paint.reset();
if (TextUtils.isEmpty(mStrokeColor)) {
return false;
}
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeCap(mStrokeLinecap);
paint.setStrokeJoin(mStrokeLinejoin);
paint.setStrokeMiter(mStrokeMiterlimit * mScale);
paint.setStrokeWidth(mStrokeWidth * mScale);
setupPaint(paint, opacity, mStrokeColor, box);
if (mStrokeDasharray != null && mStrokeDasharray.length > 0) {
paint.setPathEffect(new DashPathEffect(mStrokeDasharray, mStrokeDashoffset));
}
return true;
}
NativeLineImp.java 文件源码
项目:Virtualview-Android
阅读 28
收藏 0
点赞 0
评论 0
public void setPaintParam(int color, int paintWidth, int style) {
mPaint.setStrokeWidth(paintWidth);
mPaint.setColor(color);
mPaint.setAntiAlias(true);
switch (style) {
case STYLE_DASH:
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setPathEffect(new DashPathEffect(mBase.mDashEffect, 1));
this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
break;
case STYLE_SOLID:
mPaint.setStyle(Paint.Style.FILL);
break;
}
}
StrokeContent.java 文件源码
项目:atlas
阅读 27
收藏 0
点赞 0
评论 0
private void applyDashPatternIfNeeded() {
if (dashPatternAnimations.isEmpty()) {
return;
}
float scale = lottieDrawable.getScale();
for (int i = 0; i < dashPatternAnimations.size(); i++) {
dashPatternValues[i] = dashPatternAnimations.get(i).getValue();
// If the value of the dash pattern or gap is too small, the number of individual sections
// approaches infinity as the value approaches 0.
// To mitigate this, we essentially put a minimum value on the dash pattern size of 1px
// and a minimum gap size of 0.01.
if (i % 2 == 0) {
if (dashPatternValues[i] < 1f) {
dashPatternValues[i] = 1f;
}
} else {
if (dashPatternValues[i] < 0.1f) {
dashPatternValues[i] = 0.1f;
}
}
dashPatternValues[i] *= scale;
}
float offset = dashPatternOffsetAnimation == null ? 0f : dashPatternOffsetAnimation.getValue();
paint.setPathEffect(new DashPathEffect(dashPatternValues, offset));
}
PathEffectView.java 文件源码
项目:android-study
阅读 34
收藏 0
点赞 0
评论 0
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//无效果
mEffects[0] = null;
//拐角处变得圆滑
mEffects[1] = new CornerPathEffect(30);
//线段上就会产生许多杂点
mEffects[2] = new DiscretePathEffect(3.0F, 5.0F);
//绘制虚线
mEffects[3] = new DashPathEffect(new float[] { 20, 10, 5, 10 }, 0);
Path path = new Path();
path.addRect(0, 0, 8, 8, Path.Direction.CCW);
//设置点的图形,即方形点的虚线,圆形点的虚线
mEffects[4] = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
//组合PathEffect
mEffects[5] = new ComposePathEffect(mEffects[3], mEffects[1]);
for (int i = 0; i < mEffects.length; i++) {
mPaint.setPathEffect(mEffects[i]);
canvas.drawPath(mPath, mPaint);
canvas.translate(0, 200);
}
}
ChartHelper.java 文件源码
项目:boohee_v5.6
阅读 33
收藏 0
点赞 0
评论 0
private Line getTargetLine() {
if (!needDrawTargetLine()) {
return null;
}
PointValue lastRecordPoint = (PointValue) this.mPointValues.get(this.mPointValues.size()
- 1);
PointValue targetPoint = new PointValue(((AxisValue) this.mAxisValues.get(this
.mAxisValues.size() - 1)).getValue(), this.mTargetWeight);
List<PointValue> points = new ArrayList();
points.add(lastRecordPoint);
points.add(targetPoint);
Line line = new Line(points);
line.setColor(this.resources.getColor(R.color.da));
line.setPathEffect(new DashPathEffect(new float[]{15.0f, 15.0f, 15.0f, 15.0f}, 0.0f));
line.setHasLabels(false);
if (this.mTypeMode > 0) {
line.setHasPoints(false);
return line;
}
line.setHasPoints(true);
return line;
}
BarChart.java 文件源码
项目:boohee_v5.6
阅读 30
收藏 0
点赞 0
评论 0
private void init(Context context) {
setLayerType(1, null);
this.mContext = context;
this.mBackgroundPaint = new Paint();
this.mBackgroundPaint.setStrokeWidth(2.0f);
this.mBackgroundPaint.setAntiAlias(true);
this.mBackgroundPaint.setColor(-5056771);
this.mBackgroundPaint.setStyle(Style.STROKE);
this.mColumnPaint = new Paint();
this.mColumnPaint.setAntiAlias(true);
this.mColumnPaint.setStyle(Style.FILL);
this.mColumnPaint.setColor(-12477447);
this.mLinePaint = new Paint();
this.mLinePaint.setAntiAlias(true);
this.mLinePaint.setStyle(Style.STROKE);
this.mLinePaint.setColor(-5056771);
this.mLinePaint.setStrokeWidth(1.0f);
this.mLinePaint.setPathEffect(new DashPathEffect(new float[]{aj.hA, aj.hA}, 0.0f));
this.mBackgroundRect = new RectF();
}
WidgetTextFrame.java 文件源码
项目:Rotatable-Scalable-Font
阅读 34
收藏 0
点赞 0
评论 0
public WidgetTextFrame(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setClipChildren(false);
setClipToPadding(false);
mContext = context.getApplicationContext();
mPaddingSpace = context.getResources().getDimensionPixelSize(R.dimen.edit_text_space);
mRoundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
PathEffect effect = new DashPathEffect(new float[]{20, 20}, 1);
mRoundPaint.setAntiAlias(true);
mRoundPaint.setColor(getResources().getColor(R.color.edit_text_background_color));
mRoundPaint.setPathEffect(effect);
mRoundPaint.setStyle(Paint.Style.STROKE);
mRoundPaint.setStrokeWidth(3);
mDeletePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDeletePaint.setAntiAlias(true);
mDeletePaint.setFilterBitmap(true);
mDeletePaint.setDither(true);
setWillNotDraw(false);
}
UILine.java 文件源码
项目:HeadlineNews
阅读 53
收藏 0
点赞 0
评论 0
private void initPaint() {
mPaint = new Paint();
mPaint.setColor(mColor);
mPaint.setStyle(Paint.Style.STROKE);
/** 边界实际的位置是在边框的中间,所以都要减去边框宽度的一半,所以需要乘以2,才能得到想要的尺寸*/
mPaint.setStrokeWidth(mThickness * 2);
if (mLineMode == LINE_MODE_DOTTED) {
/** 定义 虚线的一些尺寸属性 从0开始,偶数项代表 单个虚线的长度,第二个代表虚线间隔的大小,后面会依次循环*/
float[] intervals = new float[]{mDottedSize, mDottedSpacingSize};
/** 第二个参数是 偏移量,填0就够用了*/
DashPathEffect dashPathEffect = new DashPathEffect(intervals, 0);
mPaint.setPathEffect(dashPathEffect);
}
mPath = new Path();
}
FalsifyHeader.java 文件源码
项目:SmartRefreshLayout
阅读 36
收藏 0
点赞 0
评论 0
@Override
@SuppressLint({"DrawAllocation", "SetTextI18n"})
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);
}
}
FalsifyFooter.java 文件源码
项目:SmartRefreshLayout
阅读 38
收藏 0
点赞 0
评论 0
@Override
@SuppressLint({"DrawAllocation", "SetTextI18n"})
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运行时代表上拉Footer的高度【" + 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);
}
}
TicketView.java 文件源码
项目:ticket-view
阅读 31
收藏 0
点赞 0
评论 0
private void init(AttributeSet attrs) {
eraser.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
dashPaint.setARGB(255, 200, 200, 200);
dashPaint.setStyle(Style.STROKE);
dashPaint.setStrokeWidth(4);
dashPaint.setPathEffect(new DashPathEffect(new float[] { 4, 8 }, 0));
borderPaint.setARGB(255, 200, 200, 200);
borderPaint.setStyle(Style.STROKE);
borderPaint.setStrokeWidth(4);
setLayerType(LAYER_TYPE_HARDWARE, null);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TicketView);
try {
orientation = a.getInt(R.styleable.TicketView_tv_orientation, Orientation.VERTICAL);
holeRadius = a.getFloat(R.styleable.TicketView_tv_holeRadius, DEFAULT_RADIUS);
anchorViewId = a.getResourceId(R.styleable.TicketView_tv_anchor, NO_VALUE);
} finally {
a.recycle();
}
}
BarChartRenderer.java 文件源码
项目:JZAndroidChart
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void renderHighlighted(Canvas canvas, @NonNull Highlight[] highlights) {
mRenderPaint.setColor(getHighlightColor());
mRenderPaint.setStrokeWidth(2);
mRenderPaint.setStyle(Paint.Style.STROKE);
if (mDashedHighlightPhase > 0) {
mRenderPaint.setPathEffect(new DashPathEffect(mDashedHighlightIntervals, mDashedHighlightPhase));
}
for (Highlight highlight : highlights) {
canvas.drawLine(
highlight.getX(),
0,
highlight.getX(),
mContentRect.bottom,
mRenderPaint);
}
mRenderPaint.setPathEffect(null);
}
DrawBorder.java 文件源码
项目:RNLearn_Project1
阅读 41
收藏 0
点赞 0
评论 0
@Override
protected @Nullable DashPathEffect getPathEffectForBorderStyle() {
if (isFlagSet(BORDER_PATH_EFFECT_DIRTY)) {
switch (mBorderStyle) {
case BORDER_STYLE_DOTTED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth());
break;
case BORDER_STYLE_DASHED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth() * 3);
break;
default:
mPathEffectForBorderStyle = null;
break;
}
resetFlag(BORDER_PATH_EFFECT_DIRTY);
}
return mPathEffectForBorderStyle;
}
ReactViewBackgroundDrawable.java 文件源码
项目:RNLearn_Project1
阅读 31
收藏 0
点赞 0
评论 0
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
DrawBorder.java 文件源码
项目:RNLearn_Project1
阅读 37
收藏 0
点赞 0
评论 0
@Override
protected @Nullable DashPathEffect getPathEffectForBorderStyle() {
if (isFlagSet(BORDER_PATH_EFFECT_DIRTY)) {
switch (mBorderStyle) {
case BORDER_STYLE_DOTTED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth());
break;
case BORDER_STYLE_DASHED:
mPathEffectForBorderStyle = createDashPathEffect(getBorderWidth() * 3);
break;
default:
mPathEffectForBorderStyle = null;
break;
}
resetFlag(BORDER_PATH_EFFECT_DIRTY);
}
return mPathEffectForBorderStyle;
}
ReactViewBackgroundDrawable.java 文件源码
项目:RNLearn_Project1
阅读 32
收藏 0
点赞 0
评论 0
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
DashLine.java 文件源码
项目:Coding-Android
阅读 38
收藏 0
点赞 0
评论 0
public DashLine(Context paramContext, AttributeSet paramAttributeSet) {
super(paramContext, paramAttributeSet);
//通过R.styleable.dashedline获得我们在attrs.xml中定义的
//<declare-styleable name="dashedline"> TypedArray
// TypedArray a = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.dashedline);
//我们在attrs.xml中<declare-styleable name="dashedline">节点下
//添加了<attr name="lineColor" format="color" />
//表示这个属性名为lineColor类型为color。当用户在布局文件中对它有设定值时
//可通过TypedArray获得它的值当用户无设置值是采用默认值0XFF00000
// int lineColor = a.getColor(R.styleable.dashedline_lineColor, 0XFF000000);
// a.recycle();
int lineColor = 0xffc1c1c1;
this.paint = new Paint();
this.path = new Path();
this.paint.setStyle(Paint.Style.STROKE);
this.paint.setColor(lineColor);
this.paint.setAntiAlias(true);
this.paint.setStrokeWidth(Global.dpToPx(2));
float[] arrayOfFloat = new float[4];
arrayOfFloat[0] = Global.dpToPx(3);
arrayOfFloat[1] = Global.dpToPx(2);
arrayOfFloat[2] = Global.dpToPx(3);
arrayOfFloat[3] = Global.dpToPx(2);
this.pe = new DashPathEffect(arrayOfFloat, 0);
}
ReactViewBackgroundDrawable.java 文件源码
项目:react-native-ibeacon-android
阅读 29
收藏 0
点赞 0
评论 0
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
WXBackgroundDrawable.java 文件源码
项目:weex
阅读 36
收藏 0
点赞 0
评论 0
public
@Nullable
PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[]{borderWidth * 3, borderWidth * 3, borderWidth * 3, borderWidth * 3}, 0);
case DOTTED:
return new DashPathEffect(
new float[]{borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
CSSBoxModelView.java 文件源码
项目:weex-analyzer-android
阅读 34
收藏 0
点赞 0
评论 0
private void init() {
mShapePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mShapePaint.setStrokeWidth(ViewUtils.dp2px(getContext(),1));
mShapePaint.setDither(true);
mShapePaint.setColor(COLOR_TEXT);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setDither(true);
mTextPaint.setTextSize(ViewUtils.sp2px(getContext(), 12));
mTextPaint.setColor(COLOR_TEXT);
mTextPaint.setTypeface(Typeface.DEFAULT);
Paint.FontMetrics metrics = mTextPaint.getFontMetrics();
mTextOffsetY = -(metrics.descent+metrics.ascent)/2.0f;
mTextOffsetX = (metrics.descent-metrics.ascent)/2.0f;
mCachedTextBounds = new Rect();
mViewMinWidth = DEFAULT_VIEW_WIDTH;
mViewMinHeight = DEFAULT_VIEW_HEIGHT;
mPathEffect = new DashPathEffect(new float[]{5,5,5,5},1);
}
ReactViewBackgroundDrawable.java 文件源码
项目:react-native-box-loaders
阅读 38
收藏 0
点赞 0
评论 0
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
GraphData.java 文件源码
项目:AndroidAPS
阅读 32
收藏 0
点赞 0
评论 0
public void addNowLine(GraphView graph, long now) {
LineGraphSeries<DataPoint> seriesNow;
DataPoint[] nowPoints = new DataPoint[]{
new DataPoint(now, 0),
new DataPoint(now, maxY)
};
seriesNow = new LineGraphSeries<>(nowPoints);
seriesNow.setDrawDataPoints(false);
// custom paint to make a dotted line
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
paint.setColor(Color.WHITE);
seriesNow.setCustomPaint(paint);
addSeriesWithoutInvalidate(graph, seriesNow);
}
ReactViewBackgroundDrawable.java 文件源码
项目:Ironman
阅读 34
收藏 0
点赞 0
评论 0
public @Nullable PathEffect getPathEffect(float borderWidth) {
switch (this) {
case SOLID:
return null;
case DASHED:
return new DashPathEffect(
new float[] {borderWidth*3, borderWidth*3, borderWidth*3, borderWidth*3}, 0);
case DOTTED:
return new DashPathEffect(
new float[] {borderWidth, borderWidth, borderWidth, borderWidth}, 0);
default:
return null;
}
}
LegendEntry.java 文件源码
项目:GitHub
阅读 41
收藏 0
点赞 0
评论 0
/**
*
* @param label The legend entry text. A `null` label will start a group.
* @param form The form to draw for this entry.
* @param formSize Set to NaN to use the legend's default.
* @param formLineWidth Set to NaN to use the legend's default.
* @param formLineDashEffect Set to nil to use the legend's default.
* @param formColor The color for drawing the form.
*/
public LegendEntry(String label,
Legend.LegendForm form,
float formSize,
float formLineWidth,
DashPathEffect formLineDashEffect,
int formColor)
{
this.label = label;
this.form = form;
this.formSize = formSize;
this.formLineWidth = formLineWidth;
this.formLineDashEffect = formLineDashEffect;
this.formColor = formColor;
}
FishLoadingRenderer.java 文件源码
项目:GitHub
阅读 34
收藏 0
点赞 0
评论 0
private void setupPaint() {
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(mRiverBankWidth);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.MITER);
mPaint.setPathEffect(new DashPathEffect(new float[]{mPathFullLineSize, mPathDottedLineSize}, mPathDottedLineSize));
}
ComplexAdapter.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
@Override
public Paint dividerPaint(int position, RecyclerView parent) {
Paint paint = new Paint();
switch (position % 10) {
case 0:
paint.setColor(Color.RED);
paint.setStrokeWidth(30);
break;
case 1:
paint.setColor(Color.MAGENTA);
paint.setStrokeWidth(10);
break;
default:
if (position % 2 == 0) {
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
} else {
paint.setColor(Color.GREEN);
}
paint.setStrokeWidth(2 + position);
break;
}
return paint;
}
PaintActivity.java 文件源码
项目:GitHub
阅读 36
收藏 0
点赞 0
评论 0
@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());
}