还比较像样的东西吧,暂且先绘到这里了,以后想到了再改进
就如上图所示,显示的时间是14:13:40
用到的方法是之前使用的,见http://blog.csdn.net/molu_chase/article/details/52582751
同样的显示资源文件,这个有直接用变量定义也是一样的效果
<resources>
<attr name="HourColor" format="color"/>
<attr name="MinColor" format="color"/>
<attr name="SecondColor" format="color"/>
<declare-styleable name="ClockView">
<attr name="HourColor"/>
<attr name="MinColor"/>
<attr name="SecondColor"/>
</declare-styleable>
</resources>
在布局文件中使用
<com.example.administrator.clock.ClockView
android:layout_width="match_parent"
android:layout_height="match_parent"
clock:HourColor="#aaff22"
clock:MinColor="#ffee22"
clock:SecondColor="#2233ff"/>
自定义类如下
private int mHeight, mWidth;//屏幕的高度和宽度
private int mHourColor,mMinColor,mSecondColor;//每个转盘的颜色
private int mHour,mMin,mSecond;//进度值
private int mHourWidth,mMinWidth,mSecondWidth;//进度条的宽度
public ClockView(Context context) {
this(context, null);
}
public ClockView(Context context, Attrib