最近想写一个模拟时钟的插件,也就一个小的widget可以放在桌面上。
背景  ,时针 ,分针,秒针 这些图片已经有了,
现在问题来了,如何能让时针分针秒针等等绕着一个固定的点进行旋转呢?
求解中!!!

解决方案 »

  1.   

    这不是问题,你可以设置rotate属性啊!其中有一个属性就是围绕固定点旋转的!你可以先定义一个.xml文件,在其中设置你想要的结果,然后倒入这个文件!如下,
    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
            
    <rotate 
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            
            android:fromDegrees="0" 
            android:toDegrees="+360"
                    
            android:pivotX="50%" 
            android:pivotY="50%" 
    (这两个就是设置固定旋转点)    
             
            android:duration="1000" />
    </set>
      

  2.   

    如果是你自己对图片进行旋转的话,会有点慢,你可以使用
     <AnalogClock
      android:id="@+id/AnalogClock"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:dial="@drawable/bg"
      android:hand_hour="@drawable/hour"
      android:hand_minute="@drawable/minute"/>秒针呢,则绘制好每一秒对应的图片,贴上去
      

  3.   


    这样做不可以吧!? 首先起始位置你就不能确定了。肯定刚把widget添加到桌面的时候,就会首先设置时间
    这时候就需要贴图片了。使用animation的话肯定不行。
      

  4.   

    当时以前同事在MTK上做过,高了很久。秒钟没做!