色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

Android MarkTipsView文字標(biāo)識(shí)控件使用方法

瀏覽:5日期:2022-09-19 13:17:37

本文實(shí)例為大家分享了Android MarkTipsView文字標(biāo)識(shí)控件的具體代碼,供大家參考,具體內(nèi)容如下

效果預(yù)覽

Android MarkTipsView文字標(biāo)識(shí)控件使用方法

使用

使用方式跟TextView使用方式一樣,背景設(shè)置直接setBackgroundColor

源碼:

import android.content.Context;import android.content.res.TypedArray;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Path;import android.graphics.RectF;import android.util.AttributeSet;import androidx.appcompat.widget.AppCompatTextView;/** * 繪制mark標(biāo)注 */public class MarkTipsView extends AppCompatTextView { /** * 畫筆 */ private Paint paint; /** * 寬度 */ private int width; /** * 高度 */ private int height; /** * 標(biāo)識(shí)寬度 */ private int markWidth = 12; /** * 標(biāo)識(shí)高度 */ private int markHeight = 12; /** * 圓角大小 */ private float radius = 10; /** * 填充顏色 */ private int solid = Color.parseColor('#F1AA44'); public MarkTipsView(Context context) {super(context);initAttributeSet(context, null); } public MarkTipsView(Context context, AttributeSet attrs) {super(context, attrs);initAttributeSet(context, attrs); } public MarkTipsView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);initAttributeSet(context, attrs); } private void initAttributeSet(Context context, AttributeSet attrs) {paint = new Paint();paint.setDither(true);paint.setAntiAlias(true);paint.setStyle(Paint.Style.FILL);TypedArray array = context.obtainStyledAttributes(attrs,new int[]{android.R.attr.background});solid = array.getInt(0,solid);array.recycle(); } @Override public void setBackgroundColor(int color) {solid = color;invalidate(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {super.onMeasure(widthMeasureSpec, heightMeasureSpec);width = getMeasuredWidth();height = getMeasuredHeight(); } @Override protected void onFinishInflate() {super.onFinishInflate();setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom() + markHeight); } @Override protected void onDraw(Canvas canvas) {paint.setColor(solid);//矩形Path path = new Path();RectF rect = new RectF(0, 0, width, height - markHeight);path.addRoundRect(rect, radius, radius, Path.Direction.CCW);//三角形Path onePath = new Path();onePath.lineTo(width / 2 - markWidth, rect.height());onePath.lineTo(width / 2, height);onePath.lineTo(width / 2 + markWidth, rect.height());onePath.close();path.addPath(onePath);//繪制路徑canvas.drawPath(path, paint);super.onDraw(canvas);//重繪文字setText(getText()); } /** * 獲取底部標(biāo)識(shí)箭頭高度 * @return */ public int getMarkHeight() {return markHeight; } /** * 設(shè)置底部標(biāo)識(shí)箭頭高度 * @param markHeight */ public void setMarkHeight(int markHeight) {this.markHeight = markHeight;invalidate(); } /** * 獲取底部標(biāo)識(shí)箭頭寬度 * @return */ public int getMarkWidth() {return markWidth; } /** * 設(shè)置底部標(biāo)識(shí)箭頭寬度 * @param markWidth */ public void setMarkWidth(int markWidth) {this.markWidth = markWidth;invalidate(); } /** * 獲取圓角大小 * @return */ public float getRadius() {return radius; } /** * 設(shè)置圓角大小 * @param radius */ public void setRadius(float radius) {this.radius = radius;invalidate(); }}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Android
相關(guān)文章:
主站蜘蛛池模板: 国产猛烈无遮掩视频免费网站男女 | 美国美女一级毛片免费全 | 91精品自在拍精选久久 | 亚洲国产精品67194成人 | free性丰满白嫩白嫩的hd | 亚洲精品高清视频 | 国产婷婷一区二区在线观看 | 亚洲国产精品久久久天堂 | 国产成人精品日本亚洲专一区 | 国产精品无圣光一区二区 | 深夜做爰性大片中文 | 久久久这里只有精品加勒比 | 毛片在线网站 | 欧美视频一区二区三区精品 | 日韩一区二区三区四区不卡 | 成人小视频在线播放 | 男女性男女刺激大片免费观看 | 免费久久精品视频 | 在线a亚洲视频播放在线观看 | 亚洲国产日韩欧美在线 | 操出白浆视频 | 免费一级毛片在级播放 | 一个人看的www日本视频 | 国产在线精品一区二区中文 | 国产成人免费福利网站 | 精品一区二区三区视频在线观看免 | 大陆孕妇孕交视频自拍 | 韩国一级毛片在线观看 | 亚洲精品高清在线观看 | 日韩欧美三级在线观看 | 波多野结衣中文在线 | 日韩精品久久一区二区三区 | 国产精品18久久久久久vr | 中日韩一级片 | 一级毛片免费播放 | 国产精品夫妇久久 | 中文字幕日韩国产 | 日韩在线观看一区二区三区 | 久久久久免费精品国产 | 老妇综合久久香蕉蜜桃 | 香港av三级 |