android动态壁纸---线条
android SDK2.1中有关于动态壁纸的2个演示DEMO,本人在网上查了相关资料。找到了一个演示DEMO的源代码,希望和大家分享。
同时谢谢提供代码的LZ.并且再此基础上本人做了一个简单的线条动态壁纸,后续还有动态壁纸---球的感应动作实例和大家一起分享学习。
DEMO
ALiveWall.java
package com.mwongxming.LiveWall;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Handler;
import android.os.SystemClock;
import android.service.wallpaper.WallpaperService;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
public class ALiveWall extends WallpaperService{
private final Handler mHandler = new Handler();
@Override
public Engine onCreateEngine() {
return new CubeEngine();
}
class CubeEngine extends Engine {
private final Paint mPaint = new Paint();
private float mOffset;
private float mTouchX = -1;
private float mTouchY = -1;
private long mStartTime;
private float mCenterX;
private float mCenterY;
private final Runnable mDrawCube = new Runnable() {
public void run() {
drawFrame();
}
};
private boolean mVisible;
CubeEngine() {
// Create a Paint to draw the lines for our cube
final Paint paint = mPaint;
paint.setColor(0xffffffff);
paint.setAntiAlias(true);
paint.setStrokeWidth(2);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.STROKE);
mStartTime = SystemClock.elapsedRealtime();
}
@Override
相关新闻>>
- 发表评论
-
- 最新评论 更多>>