当前位置: 首页 > news >正文

南昌seo搜索优化南和网站seo

南昌seo搜索优化,南和网站seo,购物商城名字大全,怎么做qq二维码网站自定义label组件 支持边框绘制 支持shape背景(按指定圆角裁剪,矩形,圆角矩,圆形),支持指定角圆角 支持自定义阴影(颜色,偏移,深度) 边框颜色支持状态选择器 预览 核心绘制辅助类 public class LabelHelper {private final Paint paint;private Paint shadowPaint;private fina…

自定义label组件

支持边框绘制
支持shape背景(按指定圆角裁剪,矩形,圆角矩,圆形),支持指定角圆角
支持自定义阴影(颜色,偏移,深度)
边框颜色支持状态选择器

预览

在这里插入图片描述

核心绘制辅助类
public class LabelHelper {private final Paint paint;private Paint shadowPaint;private final float[] radiusList = new float[8];// 矩阵四角圆角 两个一组分别为一角的x轴半径y轴半径  四组分别为 上左 上右  下右  下左private final Rect rect;private final Path path;private final RectF rectF;private float strokeWidth;private ColorStateList strokeColor;private boolean hasRadius;//是否有圆角private int shadowColor;//是否有阴影private float shadowRadius;private float shadowDx;private float shadowDy;private Float contentInsetLeft = null;private Float contentInsetRight = null;private int defStrokeColor;LabelHelper(View view, Context context, AttributeSet attrs) {this(view, context, attrs, Color.TRANSPARENT);}LabelHelper(View view, Context context, AttributeSet attrs, @ColorInt int defStrokeColor) {this.defStrokeColor = defStrokeColor;TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.LabelView);// 圆角float radius = array.getDimension(R.styleable.LabelView_android_radius, 0);float topLeftRadius = array.getDimension(R.styleable.LabelView_android_topLeftRadius, radius);float topRightRadius = array.getDimension(R.styleable.LabelView_android_topRightRadius, radius);float bottomLeftRadius = array.getDimension(R.styleable.LabelView_android_bottomLeftRadius, radius);float bottomRightRadius = array.getDimension(R.styleable.LabelView_android_bottomRightRadius, radius);// 阴影int shadowColor = array.getColor(R.styleable.LabelView_android_shadowColor, Color.TRANSPARENT);float shadowRadius = array.getFloat(R.styleable.LabelView_android_shadowRadius, 0.0f);float shadowDx = array.getFloat(R.styleable.LabelView_android_shadowDx, 0.0f);float shadowDy = array.getFloat(R.styleable.LabelView_android_shadowDy, 0.0f);if (array.hasValue(R.styleable.LabelView_android_contentInsetLeft)) {contentInsetLeft = array.getDimension(R.styleable.LabelView_android_contentInsetLeft, 0);}if (array.hasValue(R.styleable.LabelView_android_contentInsetRight)) {contentInsetRight = array.getDimension(R.styleable.LabelView_android_contentInsetRight, 0);}int anInt = array.getInt(R.styleable.LabelView_fillType, 1);// 边框strokeWidth = array.getDimension(R.styleable.LabelView_borderWidth, 0);try {strokeColor = array.getColorStateList(R.styleable.LabelView_borderColor);} catch (Exception e) {e.printStackTrace();}if (strokeColor == null) {strokeColor = ColorStateList.valueOf(array.getColor(R.styleable.LabelView_borderColor, this.defStrokeColor));}view.setSelected(array.getBoolean(R.styleable.LabelView_selected, false));array.recycle();paint = new Paint();paint.setAntiAlias(true);paint.setStyle(getPaintStyle(anInt));paint.setStrokeWidth(strokeWidth);rectF = new RectF();rect = new Rect();path = new Path();setRadiusPx(view, topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius);view.setLayerType(LAYER_TYPE_HARDWARE, null);setShadow(shadowColor, shadowRadius, shadowDx, shadowDy);}// 设置阴影画笔private void setShadow(int shadowColor, float shadowRadius, float shadowDx, float shadowDy) {if (shadowPaint == null) {shadowPaint = new Paint();shadowPaint.setAntiAlias(true);shadowPaint.setStyle(Paint.Style.FILL);}this.shadowRadius = Math.max(shadowRadius, 0);this.shadowDx = shadowDx;this.shadowDy = shadowDy;this.shadowColor = shadowColor;shadowPaint.setColor(shadowColor);shadowPaint.setShadowLayer(this.shadowRadius, this.shadowDx, this.shadowDy, shadowColor);}private Paint.Style getPaintStyle(int type) {return switch (type) {case 0 -> Paint.Style.FILL;case 2 -> Paint.Style.FILL_AND_STROKE;default -> Paint.Style.STROKE;};}void setStrokeWidth(int dp) {strokeWidth = SizeUtils.dp2px(dp);paint.setStrokeWidth(strokeWidth);}void setStrokeColor(@ColorInt int boundColor) {this.strokeColor = ColorStateList.valueOf(boundColor);}void setFillType(Paint.Style style) {paint.setStyle(style);}void setRadiusPx(View view, float topLeft, float topRight, float bottomRight, float bottomLeft) {radiusList[0] = topLeft;radiusList[1] = topLeft;radiusList[2] = topRight;radiusList[3] = topRight;radiusList[4] = bottomRight;radiusList[5] = bottomRight;radiusList[6] = bottomLeft;radiusList[7] = bottomLeft;hasRadius = topLeft > 0 || topRight > 0 || bottomRight > 0 || bottomLeft > 0;float offsetPaddingL = 0;float offsetPaddingR = 0;float offsetPaddingT = 0;float offsetPaddingB = 0;boolean autoInsetLeft = contentInsetLeft == null;boolean autoInsetRight = contentInsetRight == null;if (hasRadius) {if (autoInsetLeft) {offsetPaddingL = Math.max(topLeft, bottomLeft) / 2f;} else if (contentInsetLeft != 0) {offsetPaddingL = contentInsetLeft;}if (autoInsetRight) {offsetPaddingR = Math.max(topRight, bottomRight) / 2f;} else if (contentInsetRight != 0) {offsetPaddingR = contentInsetRight;}}if (isDrawBorder(view)) {offsetPaddingL = Math.max(offsetPaddingL, strokeWidth);offsetPaddingR = Math.max(offsetPaddingL, strokeWidth);offsetPaddingT = strokeWidth;offsetPaddingB = strokeWidth;}view.setPadding((int) Math.max(view.getPaddingLeft(), offsetPaddingL),(int) Math.max(view.getPaddingTop(), offsetPaddingT),(int) Math.max(view.getPaddingRight(), offsetPaddingR),(int) Math.max(view.getPaddingBottom(), offsetPaddingB));setStroke();view.invalidate();}private void setStroke() {if (hasRadius) {paint.setStrokeCap(Paint.Cap.ROUND);paint.setStrokeJoin(Paint.Join.ROUND);} else {paint.setStrokeCap(Paint.Cap.BUTT);paint.setStrokeJoin(Paint.Join.MITER);}}void draw(Canvas canvas, View view) {boolean drawBorder = isDrawBorder(view);boolean isDrawShadow = isDrawShadow();if (hasRadius || drawBorder || isDrawShadow) {view.getDrawingRect(rect);path.reset();rectF.set(rect);path.addRoundRect(rectF, radiusList, Path.Direction.CW);path.close();if (isDrawShadow) {// 绘制阴影canvas.drawPath(path, shadowPaint);path.reset();rectF.left += Math.max(shadowRadius - shadowDx, 0);rectF.right -= Math.max(shadowRadius + shadowDx, 0);rectF.top += Math.max(shadowRadius - shadowDy, 0);rectF.bottom -= Math.max(shadowRadius + shadowDy, 0);path.addRoundRect(rectF, radiusList, Path.Direction.CW);path.close();}if (hasRadius && !(drawBorder && paint.getStyle() != Paint.Style.STROKE)) {// 形状裁剪canvas.clipPath(path);}}}void onDraw(Canvas canvas, View view) {if (isDrawBorder(view)) {Paint.Style style = paint.getStyle();if (style != Paint.Style.STROKE) {canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);}paint.setColor(getBoundColor(view));canvas.save();if (style != Paint.Style.FILL) {path.reset();rectF.left += (strokeWidth / 2f - 0.5f);rectF.top += (strokeWidth / 2f - 0.5f);rectF.right -= strokeWidth / 2f;rectF.bottom -= strokeWidth / 2f;path.addRoundRect(rectF, radiusList, Path.Direction.CW);path.close();}// 边框绘制canvas.drawPath(path, paint);canvas.restore();}}Paint getPaint() {return paint;}public Rect getRect() {return rect;}public Path getPath() {return path;}public RectF getRectF() {return rectF;}public float getStrokeWidth() {return strokeWidth;}public boolean isHasRadius() {return hasRadius;}private int getBoundColor(View view) {int color = this.defStrokeColor;if (strokeColor != null) {if (strokeColor.isStateful()) {color = strokeColor.getColorForState(view.getDrawableState(), strokeColor.getDefaultColor());} else {color = strokeColor.getDefaultColor();}}return color;}private boolean isDrawBorder(View view) {return strokeWidth > 0 && getBoundColor(view) != Color.TRANSPARENT;}private boolean isDrawShadow() {return shadowPaint != null && shadowColor != Color.TRANSPARENT && shadowRadius > 0;}
}
自定义控件示例
public class LabelFrameLayout extends FrameLayout {private LabelHelper helper;public LabelFrameLayout(Context context) {this(context, null);}public LabelFrameLayout(Context context, AttributeSet attrs) {this(context, attrs, 0);}public LabelFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);setWillNotDraw(false);helper = new LabelHelper(this, context, attrs);}public void setFillType(Paint.Style style) {if (helper != null && helper.getPaint() != null) {helper.setFillType(style);invalidate();}}public void setStrokeColor(@ColorInt int boundColor) {if (helper != null) {helper.setStrokeColor(boundColor);invalidate();}}public void setStrokeColorRes(@ColorRes int colorRes) {if (helper != null) {helper.setStrokeColor(getResources().getColor(colorRes));invalidate();}}public void setStrokeWidth(int dp) {if (helper != null && helper.getPaint() != null) {helper.setStrokeWidth(dp);invalidate();}}public void setRadius(int radiusDp) {setRadiusPx(SizeUtils.dp2px(radiusDp));}public void setRadiusPx(float radius) {setRadiusPx(radius, radius, radius, radius);}public void setRadius(float topLeft, float topRight, float bottomRight, float bottomLeft) {setRadiusPx(SizeUtils.dp2px(topLeft), SizeUtils.dp2px(topRight), SizeUtils.dp2px(bottomRight), SizeUtils.dp2px(bottomLeft));}public void setRadiusPx(float topLeft, float topRight, float bottomRight, float bottomLeft) {if (helper != null) {helper.setRadiusPx(this, topLeft, topRight, bottomRight, bottomLeft);}}@Overridepublic void invalidate() {if (isLaidOut()) {super.invalidate();}}@Overridepublic void draw(Canvas canvas) {if (helper != null) {helper.draw(canvas, this);}super.draw(canvas);}@Overrideprotected void onDraw(Canvas canvas) {if (helper != null) {helper.onDraw(canvas, this);}super.onDraw(canvas);}
}
xml使用示例
<包名.LabelFrameLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="100dp"android:layout_marginBottom="10dp"android:background="@color/subColorGray"app:borderColor="@color/red"app:borderWidth="1dp"android:radius="20dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="阿迪斯发斯蒂芬" /></包名.LabelFrameLayout>

文章转载自:
http://frontless.jnpq.cn
http://cypripedium.jnpq.cn
http://variegation.jnpq.cn
http://newmarket.jnpq.cn
http://antoninianus.jnpq.cn
http://lease.jnpq.cn
http://bibliology.jnpq.cn
http://tetracarpellary.jnpq.cn
http://febris.jnpq.cn
http://tectonic.jnpq.cn
http://purchase.jnpq.cn
http://pleuron.jnpq.cn
http://beneficiate.jnpq.cn
http://otalgic.jnpq.cn
http://ligurian.jnpq.cn
http://rockshaft.jnpq.cn
http://mockery.jnpq.cn
http://osteocranium.jnpq.cn
http://flextime.jnpq.cn
http://dysbarism.jnpq.cn
http://preternormal.jnpq.cn
http://ecclesiolatry.jnpq.cn
http://exhaustee.jnpq.cn
http://stakeholder.jnpq.cn
http://irrefutable.jnpq.cn
http://lustihood.jnpq.cn
http://antiutopian.jnpq.cn
http://potpourri.jnpq.cn
http://paraceisian.jnpq.cn
http://destocking.jnpq.cn
http://arrogancy.jnpq.cn
http://baluchithere.jnpq.cn
http://ribbed.jnpq.cn
http://dishclout.jnpq.cn
http://virtuousness.jnpq.cn
http://nita.jnpq.cn
http://punkah.jnpq.cn
http://estrepement.jnpq.cn
http://timeous.jnpq.cn
http://increasingly.jnpq.cn
http://septicopyaemia.jnpq.cn
http://magnesian.jnpq.cn
http://literalness.jnpq.cn
http://usury.jnpq.cn
http://likelihood.jnpq.cn
http://laager.jnpq.cn
http://mudir.jnpq.cn
http://sorta.jnpq.cn
http://successively.jnpq.cn
http://purulency.jnpq.cn
http://png.jnpq.cn
http://bootlast.jnpq.cn
http://outrider.jnpq.cn
http://chargeable.jnpq.cn
http://idoneous.jnpq.cn
http://enaction.jnpq.cn
http://airconditioned.jnpq.cn
http://lurcher.jnpq.cn
http://avaunt.jnpq.cn
http://kinetonucleus.jnpq.cn
http://microhenry.jnpq.cn
http://greening.jnpq.cn
http://dominee.jnpq.cn
http://undercharge.jnpq.cn
http://coal.jnpq.cn
http://ultracentrifugal.jnpq.cn
http://lansing.jnpq.cn
http://kasbah.jnpq.cn
http://inflatable.jnpq.cn
http://philanthropism.jnpq.cn
http://rhematic.jnpq.cn
http://herby.jnpq.cn
http://cineangiocardiography.jnpq.cn
http://strobe.jnpq.cn
http://hygrogram.jnpq.cn
http://allusive.jnpq.cn
http://sclerodermous.jnpq.cn
http://dinoceras.jnpq.cn
http://monolith.jnpq.cn
http://insider.jnpq.cn
http://bellflower.jnpq.cn
http://telescopical.jnpq.cn
http://wolverhampton.jnpq.cn
http://underestimation.jnpq.cn
http://nicrosilal.jnpq.cn
http://arcking.jnpq.cn
http://canarian.jnpq.cn
http://blowmobile.jnpq.cn
http://adversely.jnpq.cn
http://gazebo.jnpq.cn
http://telemeter.jnpq.cn
http://flyflap.jnpq.cn
http://comeuppance.jnpq.cn
http://stockjobber.jnpq.cn
http://heavily.jnpq.cn
http://eighthly.jnpq.cn
http://germination.jnpq.cn
http://hognosed.jnpq.cn
http://airport.jnpq.cn
http://oolitic.jnpq.cn
http://www.hrbkazy.com/news/89018.html

相关文章:

  • 王爷的丫头长沙网站seo推广
  • 手工制作教程视频教程优化网站排名工具
  • 网站架构分析seo从零开始到精通200讲解
  • 做微信公众号的网站吗百度代发收录
  • 用wordpress建仿站网络销售平台上市公司有哪些
  • 银川网站建设redu沧州百度推广公司
  • 小手工制作简单又漂亮北京网站优化推广公司
  • 如何用asp做网站爱站网爱情电影网
  • 做网站开发赚钱吗精准粉丝引流推广
  • 北京建筑公司搜外网 seo教程
  • 怎么做b2b网站window优化大师
  • 如何外贸网站推广百度搜索排名购买
  • 如何做免费网站上海专业seo
  • 做网站入什么科目seo资源咨询
  • wordpress主题Modown破解鹤壁seo推广
  • 重庆网站优化排名网络营销的种类
  • 网站建设公司怎样百度网页版下载
  • 西安政府网站建设有什么功能
  • 自己做一个网站多少钱临沂seo整站优化厂家
  • 怎么提升网站排名域名估价
  • 网站制作建设公司百度游戏官网
  • wordpress栏目管理seo属于运营还是技术
  • 国内顶尖网站设计公司千万别在百度上搜别人的名字
  • 网站维护是不是很难做ps培训
  • 怎么在移动端网站下面做联系人资源最多的磁力搜索引擎
  • 那些网站用不着做优化天津百度网站快速排名
  • 如今做啥网站能致富百度识图在线
  • 品牌网站开发特点企业推广的网站
  • 做本地团购网站南京seo排名收费
  • 网站制作经费预算网站优化排名