package com.slide.bao;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff.Mode;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class FaceCanvas extends SurfaceView implements SurfaceHolder.Callback {
public int iWidth = 500;
public int getiWidth() {
return iWidth;
}
public void setiWidth(int iWidth) {
this.iWidth = iWidth;
}
public int iHeight = 100;
public int getiHeight() {
return iHeight;
}
public void setiHeight(int iHeight) {
this.iHeight = iHeight;
}
public Draw draw;
public Context context;
public Slider slider;
public Paint paint;
public Bitmap[] bitmap = new Bitmap[9];
public int iWidthS = 0;
public int iHeightS = 0;
public FaceCanvas(Context context, int iWidthS, int iHeightS) {
super(context);
this.context = context;
getHolder().addCallback(this);
draw = new Draw(this, getHolder());
this.iWidthS = iWidthS / 5;// 同时控制
Variable.bMeanWhile = true;// 同时控制标签
this.iHeightS = iHeightS;
init();
}
public FaceCanvas(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public FaceCanvas(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
}
public void init() {
bitmap[0] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_soso_bg);
bitmap[1] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.as);
bitmap[2] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_activity_button_nor);
bitmap[3] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_chat_shortcuts_nor);
bitmap[4] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_bar_news_over);
bitmap[5] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_bar_mail_over);
bitmap[6] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_bar_qzone_over);
bitmap[7] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_bar_set_over);
bitmap[8] = BitmapFactory.decodeResource(context.getResources(),
R.drawable.s0_bar_more_over);
slider = new Slider(bitmap, iWidthS, iHeightS);
paint = new Paint();
paint.setColor(Color.BLACK);
}
public void doDraw(Canvas canvas) {
slider.drawSelf(canvas);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
holder.setFormat(PixelFormat.TRANSPARENT);
setZOrderOnTop(true);
threadStart();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (draw != null) {
draw.bFlag = false;
draw = null;
}
}
public void threadStart() {
new Thread(new Runnable() {
public void run() {
if (draw != null) {
draw.paint();
}
}
}).start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int iGetX = (int) event.getX();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (Variable.isbAnimotionFlag()) {
this.slider.sliderThread.iTs = 0;
this.slider.iLeftX = (this.slider.iLeftX / iWidthS) * iWidthS;
this.slider.iDistance = (iGetX / iWidthS) * iWidthS
- this.slider.iLeftX;
this.threadStart();
} else {
this.slider.iLeftX = (iGetX / iWidthS) * iWidthS;
}
break;
default:
break;
}
return true;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Android SurfaceView 多线程 滑块
共64个文件
png:36个
class:11个
java:7个
4星 · 超过85%的资源 需积分: 9 35 下载量 160 浏览量
2011-12-12
18:17:34
上传
评论
收藏 521KB ZIP 举报
温馨提示
android demo,使用SurfaceView,使用多线程技术,可以滑动的选择按钮组,动画效果非常流畅,按钮数量可以随意改变。
资源推荐
资源详情
资源评论
收起资源包目录
Slide.zip (64个子文件)
Slide
.project 841B
default.properties 362B
bin
com
slide
bao
R$string.class 1KB
R$layout.class 1024B
R$drawable.class 2KB
SliderThread.class 867B
R.class 1KB
Variable.class 973B
R$attr.class 970B
Slider.class 4KB
Draw.class 2KB
SlideActivity.class 5KB
FaceCanvas.class 7KB
proguard.cfg 1KB
.settings
org.eclipse.core.resources.prefs 158B
AndroidManifest.xml 717B
src
com
slide
bao
Draw.java 852B
FaceCanvas.java 4KB
SlideActivity.java 3KB
Variable.java 688B
Slider.java 3KB
SliderThread.java 644B
res
values
strings.xml 169B
layout
main.xml 382B
drawable-ldpi
icon.png 2KB
drawable-hdpi
s0_photo_button_pressed.png 969B
s0_music_list_bg.png 3KB
s0_qzone_empty_icon.png 4KB
s0_music_albumn_pic.png 3KB
message_widget_unread_bg.png 2KB
s0_bar_set_over.png 4KB
qq.gif 16KB
s0_cam_left1.png 3KB
back.png 395KB
s0_bar_more_over.PNG 5KB
s0_browser_load_bg.png 449B
s0_selector_nor.png 202B
t.png 68B
s0_chat_shortcuts_nor.png 748B
s0_bar_qzone_over.png 4KB
s0_friend_search_bg.PNG 2KB
as.PNG 591B
back.JPG 6KB
s0_wblog_unregist_icon.png 4KB
s0_bar_mail_over.png 3KB
huanying.png 15KB
s0_activity_button_over.png 448B
s0_activity_button_nor.png 486B
transpant.png 68B
s0_qmail_unregist_icon.png 4KB
s0_tab_unselected.png 1KB
s0_soso_bg.png 1KB
s0_chat_shortcuts_over.png 729B
s0_wblog_empty_icon.png 2KB
s0_message_tips_bg.png 694B
s0_bar_news_over.png 4KB
s0_user_widget_pop_table_click.png 1KB
s0_btn_gray_touch.png 1KB
icon.png 4KB
asd.PNG 471B
s0_music_bg.png 6KB
drawable-mdpi
icon.png 3KB
.classpath 280B
gen
com
slide
bao
R.java 3KB
assets
共 64 条
- 1
chianidfeizhang
- 粉丝: 4
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页