package com.test.t2;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.SurfaceHolder.Callback;
public class SurfaceViewANDViewTest extends SurfaceView implements Callback {
boolean flg=false;
SurfaceHolder holder=null;
int y=10;
int []colors=new int[]{Color.BLUE,Color.YELLOW,Color.RED};
int i=0;
//构造方法
public SurfaceViewANDViewTest(Context context,
AttributeSet set) {
super(context,set);
holder=this.getHolder();
holder.addCallback(this);
}
public Thread createThread()
{
return new Thread(){
public void run()
{
while(flg)
{
Canvas canvas= holder.lockCanvas();
Paint p=new Paint();
p.setColor(colors[i]);
canvas.drawColor(Color.WHITE);
canvas.drawCircle(200, y,50,p);
y+=50;
if(y>=canvas.getHeight())
y=10;
i++;
if(i==colors.length)
i=0;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
holder.unlockCanvasAndPost(canvas);
}
}
};
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
//要重新画界面的方法
createThread().start();
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
anroid使用surfaceView画不停移动的圆形
共35个文件
class:15个
java:6个
xml:4个
4星 · 超过85%的资源 需积分: 32 33 下载量 134 浏览量
2013-05-15
16:16:03
上传
评论
收藏 54KB RAR 举报
温馨提示
anroid使用surfaceView画不停移动的圆形,使用线程在canvas中画圆形,并且改变其xy.
资源推荐
资源详情
资源评论
收起资源包目录
surfaceviewTest.rar (35个子文件)
surfaceviewTest
.project 843B
proguard.cfg 1KB
src
com
test
t2
SurfaceViewTest.java 2KB
MainActivity.java 1KB
SurfaceViewANDViewTest.java 2KB
SurfaceViewActivity.java 331B
SurfaceViewANDViewActivity.java 836B
AndroidManifest.xml 931B
res
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
drawable-mdpi
icon.png 3KB
layout
serfaceviewandview.xml 591B
main.xml 409B
values
strings.xml 169B
assets
gen
com
test
t2
R.java 895B
default.properties 362B
.classpath 280B
bin
resources.ap_ 11KB
com
test
t2
R$layout.class 415B
SurfaceViewANDViewTest.class 2KB
R$drawable.class 379B
R$attr.class 319B
SurfaceViewANDViewActivity.class 1KB
SurfaceViewTest$1.class 2KB
SurfaceViewANDViewActivity$1.class 1KB
R$id.class 422B
SurfaceViewActivity.class 671B
SurfaceViewTest.class 1KB
R.class 482B
R$string.class 406B
MainActivity$1.class 1KB
MainActivity.class 1KB
SurfaceViewANDViewTest$1.class 2KB
game_t2.apk 17KB
classes.dex 8KB
共 35 条
- 1
资源评论
- zxk_liuke2014-12-17感觉不是很好呀
- sinat_240684512015-08-24还行吧,感谢
- Name_Vinny2014-01-16还不错,适合新手
YIXIAOYING
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功