设为首页 加入收藏

TOP

Android项目实战(二十三):仿QQ设置App全局字体大小(二)
2017-10-13 10:47:31 】 浏览:7078
Tags:Android 项目 实战 二十三 设置 App 全局 字体 大小
44 spot_on = BitmapFactory.decodeResource(getResources(),R.mipmap.img_setting_seekbar_thumbe); //这个是已经滑动过的界点的图标 45 bitMapHeight = thumb.getHeight()/2; //这里影响点中的图标的位置 这个正好 不用改 46 textMove = bitMapHeight+ 5; //xqx 这里参数大小要改,不是固定的,具体看项目效果 47 textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()); //文字大小,第二个参数个人设置 48 circleRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics()); 49 mPaint = new Paint(Paint.DITHER_FLAG); 50 mPaint.setAntiAlias(true);//锯齿不显示 51 mPaint.setStrokeWidth(3); 52 mTextPaint = new Paint(Paint.DITHER_FLAG); 53 mTextPaint.setAntiAlias(true); 54 mTextPaint.setTextSize(textSize); 55 mTextPaint.setColor(0xffb5b5b4); 56 buttonPaint = new Paint(Paint.DITHER_FLAG); 57 buttonPaint.setAntiAlias(true); 58 59 } 60 /** 61 * 实例化后调用,设置bar的段数和文字 62 */ 63 public void initData(ArrayList<String> section){ 64 if(section != null){ 65 section_title = section; 66 }else { 67 //如果没有传入正确的分类级别数据,则默认使用“低”“中”“高” 68 String[] str = new String[]{"", "", ""}; 69 section_title = new ArrayList<String>(); 70 for (int i = 0; i < str.length; i++) { 71 section_title.add(str[i]); 72 } 73 } 74 } 75 76 @Override 77 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 78 super.onMeasure(widthMeasureSpec, heightMeasureSpec); 79 80 int widthMode = MeasureSpec.getMode(widthMeasureSpec); 81 int widthSize = MeasureSpec.getSize(widthMeasureSpec); 82 int heightMode = MeasureSpec.getMode(heightMeasureSpec); 83 int heightSize = MeasureSpec.getSize(heightMeasureSpec); 84 85 width = widthSize; 86 float scaleX = widthSize / 1080; 87 float scaleY = heightSize / 1920; 88 scale = Math.max(scaleX,scaleY); 89 //控件的高度 90 //height = 185; 91 height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 62, getResources().getDisplayMetrics()); 92 setMeasuredDimension(width, height); 93 width = width-bitMapHeight/2; 94 perWidth = (width - section_title.size()*spot.getWidth() - thumb.getWidth()/2) / (section_title.size()-1); 95 hotarea = perWidth/2; 96 } 97 98 @Override 99 protected void onDraw(Canvas canvas) { 100 super.onDraw(canvas); 101 mPaint.setColor(Color.WHITE); 102 mPaint.setStyle(Paint.Style.FILL); 103 mPaint.setAlpha(0); 104 canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), mPaint); 105 canvas.drawBitmap(bitmap, 0, 0, null); 106 mPaint.setAlpha(255); 107 mPaint.setColor(colors[1]); 108 canvas.drawLine(bitMapHeight, height * 2 / 3, width - bitMapHeight - spot_on.getWidth() / 2, height * 2 / 3, mPaint); 109 int section = 0; 110 while(section < section_title.size()){ 111 if(section < cur_sections) { 112 mPaint.setColor(colors[0]); 113 canvas.drawLine(thumb.getWidth()/2 + section * perWidth + (section+1) * spot_on.getWidth(),height * 2 / 3, 114 thumb.getWidth()/2 + section * perWidth + (section+1) * spot_on.getWidth() + perWidth,height * 2 / 3,mPaint); 115 canvas.drawBitmap(spot_on, thumb.getWidth()/2 + section * perWidth + section * spot_on.getWidth(),height * 2 / 3 - spot_on.getHeight()/2,mPaint); 116 }else{ 117 mPaint.setAlpha(255); 118 if(section == section_title.size
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇对于HDMI设备连接状态的监听 下一篇Android高效计算——RenderScript..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目