289_自定义小进度条
来源:互联网 发布:软件系统验收规范 编辑:程序博客网 时间:2024/06/10 10:12
自定义小进度条
public DotView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.BLACK);
//小圆的半径
radius = 5;
//小圆的直径
diameter = radius * 2;
//小圆的间距
gap = 5;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//假设来10个圆,那么宽就是10*(10*2+5)+5=255
//高就给圆的直径就行了
int width = 10 * (diameter + gap) + gap;
int height = diameter;
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//第一个圆的xy是(10+5)*1-5,10,也就是(gap+radius)*1,radius
//第二个圆的xy是(10+5)*2-5,10
for (int i = 1; i <= 10; i++) {
canvas.drawCircle((diameter + gap) * i - radius, radius, radius, paint);
}
}
public ProgressView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
HorizontalScrollView hv = (HorizontalScrollView) View.inflate(context, R.layout.view_ll, this);
LinearLayout view = (LinearLayout) hv.findViewById(R.id.ll);
for (int i = 0; i < 5; i++) {
ImageView imageView = new ImageView(context);
view.addView(imageView);
ViewGroup.LayoutParams layoutParams1 = imageView.getLayoutParams();
layoutParams1.width = 30;
layoutParams1.height = 30;
imageView.setLayoutParams(layoutParams1);
imageView.setImageResource(R.mipmap.ic_launcher);
if (i != 4) {
DotView dotView = new DotView(context);
view.addView(dotView);
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) dotView.getLayoutParams();
layoutParams2.gravity = Gravity.CENTER_VERTICAL;
}
}
}
0 0
- 289_自定义小进度条
- 自定义控件之_自定义圆形进度条
- 530_自定义彩色进度条SeekBar
- UIActivityIndicatorView 进度条(小菊花)-> 后面也可以自定义一个进度条
- #小美化#android 自定义进度条ProgressBar
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- 自定义进度条
- redis 安装 随笔
- SDUTACM 数据结构实验之链表九:双向链表
- hihocoder1385 A Simple Job JAVA String split 字符串切割
- 初识Linux内核-和CMOS打电话
- 第一章 算法在计算中的作用
- 289_自定义小进度条
- 一起来学activeMQ 5.pub/sub ,non-persistent/persistent,queue
- 确定字符互异
- 解决:Error:Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy
- 使用npm发布自己的包到npm官网上
- Number Sequence (排列组合)
- 290_自定义View固定大小
- Coding+Hexo搭建个人静态博客
- PHP变量赋值