设为首页 加入收藏

TOP

android自定义ImageView仿图片上传(二)
2017-10-12 13:27:42 】 浏览:8975
Tags:android 定义 ImageView 图片 上传
sp;}  
27             }   28         }).start();   29     }   30 }  

 

自定义view

 1 public class ProcessImageView extends ImageView{  
 2     private Context context;  
 3     private Paint paint;  
 4     private LogUtil log=LogUtil.getInstance();  
 5     int progress = 0;  
 6     private boolean flag;  
 7   
 8     public ProcessImageView(Context context) {  
 9         super(context);  
10     }  
11   
12     public ProcessImageView(Context context, AttributeSet attrs) {  
13         this(context, attrs,0);  
14     }  
15   
16     public ProcessImageView(Context context, AttributeSet attrs, int defStyleAttr) {  
17         super(context, attrs, defStyleAttr);  
18         this.context=context;  
19         paint=new Paint();  
20     }  
21   
22     @Override  
23     protected void onDraw(Canvas canvas) {  
24         super.onDraw(canvas);  
25         paint.setAntiAlias(true); //消除锯齿  
26         paint.setStyle(Paint.Style.FILL); //设置paint为实心,  Paint.Style.STROKE为空心  
27         paint.setColor(Color.parseColor("#70000000")); //设置为半透明  
28         canvas.drawRect(0,0,getWidth(),getHeight()-getHeight()*progress/100,paint); //这里getWidth() 获取的是image对象宽高度 xml值*2  
29   
30         paint.setColor(Color.parseColor("#00000000"));// 全透明  
31         canvas.drawRect(0, getHeight() - getHeight() * progress / 100,  
32                 getWidth(), getHeight(), paint);  
33   
34    &nb
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇android:configChanges属性总结 下一篇回顾自定义view三个构造函数

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目