自定义时钟

还比较像样的东西吧,暂且先绘到这里了,以后想到了再改进


就如上图所示,显示的时间是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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值