自定义圆形进度条

2018-08-16  本文已影响0人  Summer_27d1
image.png
image.png

布局中


image.png image.png
image.png

首先创建一个项目 在创建一个类RoundProgress 继承View
布局中定义控件 :


image.png
这里引用了这行代码 image.png

在 values文件夹下建一个xml


image.png

里面代码:
···
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="RoundProgress">
    <attr name="roundColor" format="color"></attr>
    <attr name="roundProgressColor" format="color"></attr>
    <attr name="textColor" format="color"></attr>
    <attr name="roundWith" format="dimension"></attr>
    <attr name="textSize" format="dimension"></attr>
    <attr name="progress" format="integer"></attr>
    <attr name="max" format="integer"></attr>


</declare-styleable>

</resources>
···

RoundProgress类中的具体代码:
···
package com.atguigu.p2pinvest0828.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

import com.atguigu.p2pinvest0828.R;
import com.atguigu.p2pinvest0828.util.UIUtils;

/**

···
效果图:


image.png
上一篇 下一篇

猜你喜欢

热点阅读