我从网上找到了自定义roundProgressBar的代码,使用之后,发现在xml中定义组建的属性没有作用,生成的roundProgressBar只是使用了默认配置
attributes:
<!--
max 最大进度
startAngle 进度从圆环的哪个角度开始走
backColor 圆环内部的填充色
roundColor 圆环的颜色
roundProgressColor 圆环进度的颜色
roundWidth 圆环宽度
textColor 中心文字的颜色
textSize 中心文字的大小
textIsDisplayable 中心文字是否显示
style = 0/1 进度的风格,实心或者空心
-->
roundProgressBar中获取定义属性并赋值:
TypedArray mTypedArray = context.obtainStyledAttributes(attrs,
R.styleable.RoundProgressBar);
//获取自定义属性和默认值,第一个参数是从用户属性中得到的设置,如果用户没有设置,那么就用默认的属性,即:第二个参数
//圆环的颜色
roundColor = mTypedArray.getColor(bm.org.uidemo.R.styleable.RoundProgressBar_roundColor, Color.parseColor("#f9e0e1"));
//圆环进度条的颜色
roundProgressColor = mTypedArray.getColor(R.styleable.RoundProgressBar_roundProgressColor, Color.parseColor("#ef7b55"));
//文字的颜色
textColor = mTypedArray.getColor(R.styleable.RoundProgressBar_textColor, Color.parseColor("#be7e77"));
//文字的大小
textSize = mTypedArray.getDimension(R.styleable.RoundProgressBar_textSize, 20);
//圆环的宽度
roundWidth = mTypedArray.getDimension(R.styleable.RoundProgressBar_roundWidth, 10);
//最大进度
max = mTypedArray.getInteger(R.styleable.RoundProgressBar_max, 100);
//是否显示中间的进度
textIsDisplayable = mTypedArray.getBoolean(R.styleable.RoundProgressBar_textIsDisplayable, true);
//进度的风格,实心或者空心
style = mTypedArray.getInt(R.styleable.RoundProgressBar_style, 0);
//进度开始的角度数
startAngle = mTypedArray.getInt(R.styleable.RoundProgressBar_startAngle, -90);
// 圆形颜色
backColor = mTypedArray.getColor(R.styleable.RoundProgressBar_backColor, Color.parseColor("#f8f8f8"));
mTypedArray.recycle();
xml中的定义代码:
<bm.org.uidemo.RoundProgressBar
android:id="@+id/investment_RoundProgressBar"
android:layout_width="38dip"
android:layout_height="71dip"
android:layout_marginTop="15dip"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"
android_custom:backColor="#f8f8f8"
android_custom:startAngle="0"
android_custom:roundColor="#000000"
android_custom:roundProgressColor="#ffffff"
android_custom:roundWidth="90dp"
android_custom:textColor="#be7e77"
android_custom:textSize="20sp"
/>
能有大大告诉我为啥设置没有生效吗??