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

网站索引量怎么做网站小图标

网站索引量,怎么做网站小图标,网站数据分析,c2c电商平台有哪些家本节介绍自定义view-圆形进度条思路#xff1a;根据前面介绍的自定义view内容可拓展得之#xff1b;1#xff1a;新建类继承自View2#xff1a;添加自定义view属性3#xff1a;重写onDraw(Canvas canvas)4#xff1a;实现功能下面上代码1.自定义view代码#xff1a; pub…本节介绍自定义view-圆形进度条 思路 根据前面介绍的自定义view内容可拓展得之 1新建类继承自View 2添加自定义view属性 3重写onDraw(Canvas canvas) 4实现功能 下面上代码1.自定义view代码 public class CustomView extends View {//背景圆环颜色private int circleColor;//进度条颜色字体颜色(为了美观所以设计字体颜色和进度条颜色值一致)private int secondCircleColor;//进度条背景圆环宽度private float stroke_width;//进度值private float progress;//总进度值默认为100private float totalProgress;//字体大小private float textSize;//填充模式private int style_type;public CustomView(Context context) {super(context);}public CustomView(Context context, AttributeSet attrs) {super(context, attrs);TypedArray arraycontext.obtainStyledAttributes(attrs, R.styleable.CustomView);circleColorarray.getColor(R.styleable.CustomView_circleColor, Color.BLACK);secondCircleColorarray.getColor(R.styleable.CustomView_secondCircleColor, Color.RED);stroke_widtharray.getDimension(R.styleable.CustomView_stroke_width, 2);progressarray.getFloat(R.styleable.CustomView_progress, 0);totalProgressarray.getFloat(R.styleable.CustomView_totalProgress, 100);textSizearray.getDimension(R.styleable.CustomView_textSize, 16);style_typearray.getInt(R.styleable.CustomView_style_Type, 0);}public CustomView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}public void setCircleColor(int color){circleColorcolor;}public int getCircleColor(){return circleColor;}public void setSecondCircleColor(int color){secondCircleColorcolor;}public int getSecondColor(){return secondCircleColor;}public void setStrokeWidth(float width){stroke_widthwidth;}public float getStrokeWidth(){return stroke_width;}public void setProgress(float progress){this.progressprogress;postInvalidate();//刷新界面}public float getProgress(){return this.progress;}public void setTotalProgress(float totalProgress){this.totalProgresstotalProgress;}public float getTotalProgress(){return this.totalProgress;}public void setTextSize(float textSize){this.textSizetextSize;}public float getTextSize(){return this.textSize;}Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);//第一进度圆final Paint paint_backgroundnew Paint();paint_background.setAntiAlias(true);paint_background.setStrokeWidth(stroke_width);paint_background.setStyle(Style.STROKE);paint_background.setColor(circleColor);//第二进度圆final Paint paint_progressnew Paint();paint_progress.setAntiAlias(true);paint_progress.setStrokeWidth(stroke_width);if(style_type0){paint_progress.setStyle(Style.STROKE);}else if(style_type1){paint_progress.setStyle(Style.FILL_AND_STROKE);}paint_progress.setColor(secondCircleColor);//画textfinal Paint paint_textnew Paint();paint_text.setAntiAlias(true);if(style_type0){paint_text.setColor(secondCircleColor);}else if(style_type1){paint_text.setColor(circleColor);}paint_text.setTextSize(textSize);paint_text.setTextAlign(Align.CENTER);if(getWidth()!getHeight()){throw new IllegalArgumentException(高度和宽度必须相等);//控制宽度和高度}else{RectF circle_backgroundnew RectF();circle_background.leftgetLeft()stroke_width;circle_background.rightgetRight()-stroke_width;circle_background.topgetTop()stroke_width;circle_background.bottomgetBottom()-stroke_width;canvas.drawArc(circle_background, -90, 360, false, paint_background);RectF circle_progressnew RectF();circle_progress.leftgetLeft()stroke_width;circle_progress.rightgetRight()-stroke_width;circle_progress.topgetTop()stroke_width;circle_progress.bottomgetBottom()-stroke_width;if(progresstotalProgress){throw new IllegalArgumentException(当前进度值不能大于总进度值);}else{if(style_type0){canvas.drawArc(circle_progress, -90, progress/totalProgress*360, false, paint_progress);}else if(style_type1){canvas.drawArc(circle_progress, -90, progress/totalProgress*360, true, paint_progress);}}canvas.drawText((int)progress/(int)totalProgress, getLeft()getWidth()/2, getTop()getHeight()/2textSize/4, paint_text);}}} 2attr属性 ?xml version1.0 encodingutf-8? resources!--declare-styleable:声明样式类型;attr name声明属性名;format属性的类型 --declare-styleable nameCustomEditTextattr namelineColor formatcolor /attr namelineHeight formatdimension//declare-styleabledeclare-styleable nameCustomViewattr namestroke_width formatdimension/attr namecircleColor formatcolor/attr namesecondCircleColor formatcolor/attr nameprogress formatfloat/attr nametotalProgress formatfloat/attr nametextSize formatdimension/attr namestyle_Typeenum namestroke value0/enum namestroke_and_fill value1//attr/declare-styleable/resources3xml布局文件 RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthwrap_contentandroid:layout_heightwrap_content com.anqiansong.views.CustomViewxmlns:circlehttp://schemas.android.com/apk/res/com.anqiansong.androidcustomviewandroid:idid/customviewandroid:layout_width50dpandroid:layout_height50dpandroid:layout_centerInParenttruecircle:circleColor#000000circle:secondCircleColor#ff0000circle:stroke_width2dpcircle:totalProgress100 circle:progress10circle:style_Typestroke//RelativeLayout 当xml文件中circle:style_Typestroke时 当xml文件中circle:style_Typestroke_and_fill时 4activity中调用 public class MainActivity extends ActionBarActivity {CustomView customView;private float progress0;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);customView(CustomView) findViewById(R.id.customview);handler.sendEmptyMessageDelayed(0, 1000);}Handler handlernew Handler(){public void handleMessage(android.os.Message msg) {if(msg.what0){if(progress100){return;}else{customView.setProgress(progress);progress2;handler.sendEmptyMessageDelayed(0, 100);}}};};} 当xml文件中circle:style_Typestroke_and_fill时
http://www.huolong8.cn/news/253039/

相关文章:

  • dw做的网站成品企业所得税25%怎么计算
  • 杭州微跑网站建设公司平面设计包括哪些内容
  • 建设黑彩网站大型网站域名
  • 太原建站网站模板万网 网站建设合同
  • 网站开发需要什么费用乌克兰网站建设
  • 网站建设中扒站为什么是违法的有意义的网站
  • 网站开发系统规划聊大 网站设计
  • 门户网站建设进度西地那非片能延时多久
  • 立邦刷新服务多少钱一平米西安做网站seo
  • 做网站图片广告推广怎么忽悠人的网站 备案地
  • 一个网站做数据维护需要多久网络服务器可提供的常见服务有什么服务
  • 个人网站建设中代码下载如何注册一个企业邮箱
  • 做网站广告收入封面设计网站有哪些
  • 驾校网站建设费用seo优化内容
  • 百度站长平台网页版邮箱域名怎么填写
  • 市场监督管理局是干什么的搜索引擎优化的各种方法
  • wordpress媒体播放器广州网站优化外包
  • 渭南网站建设推广网站做优化和推广哪个好
  • 辽宁pc网站建设开发百度快照 网站描述 更新
  • 专业的手机网站建设公司百度站内搜索提升关键词排名
  • 装修公司做网站黄骅市属于沧州吗
  • 专业建站网产品网络推广福建省 园区网互联及网站建设 网络部分题目
  • 潮州网站seo网站建设空间多大
  • 做商业地产常用的网站衡水做企业网站的公司
  • 百度网站怎么提升排名网站建设经费的请示
  • 如何注销网站域名微信管理系统后台
  • 网络服装网站建设幼儿教育网站源码
  • 网站建设都需要哪些资质网页设计与制作实训室厂家
  • 公司做网站合同桂阳网站建设
  • 免费个人网站2018镇江优化九一