位置: 编程技术 - 正文
推荐整理分享android刮刮奖效果(刮刮奖软件下载),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:刮刮卡手机软件,刮刮奖软件,刮刮奖软件,刮刮卡手机版,刮刮卡手机版,手机刮刮奖下载,android 刮刮卡,android刮刮乐,内容如对您有帮助,希望把文章链接给更多的朋友!
android刮刮奖效果
自定义View盖在textView上
import android.content.Context;import android.graphics.Bitmap;import android.graphics.Bitmap.Config;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Path;import android.graphics.PorterDuff.Mode;import android.graphics.PorterDuffXfermode;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View;public class EraseView extends View { private boolean isMove = false; private Bitmap bitmap = null; private Bitmap frontBitmap = null; private Path path; private Canvas mCanvas; private Paint paint; public EraseView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onDraw(Canvas canvas) { if (mCanvas == null) { EraseBitmp(); } canvas.drawBitmap(bitmap, 0, 0, null); mCanvas.drawPath(path,paint); super.onDraw(canvas); } public void EraseBitmp() { bitmap = Bitmap.createBitmap(getWidth(),getHeight(), Bitmap.Config.ARGB_); frontBitmap = CreateBitmap(Color.GRAY,getWidth(),getHeight()); paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); paint.setAntiAlias(true); paint.setDither(true); paint.setStrokeJoin(Paint.Join.ROUND); paint.setStrokeCap(Paint.Cap.ROUND); paint.setStrokeWidth(); path = new Path(); mCanvas = new Canvas(bitmap); mCanvas.drawBitmap(frontBitmap, 0, 0,null); } @Override public boolean onTouchEvent(MotionEvent event) { float ax = event.getX(); float ay = event.getY(); if (event.getAction() == MotionEvent.ACTION_DOWN) { isMove = false; path.reset(); path.moveTo(ax, ay); invalidate(); return true; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { isMove = true; path.lineTo(ax,ay); invalidate(); return true; } return super.onTouchEvent(event); } public Bitmap CreateBitmap(int color,int width, int height) { int[] rgb = new int [width * height]; for (int i=0;i<rgb.length;i) { rgb[i] = color; } return Bitmap.createBitmap(rgb, width, height,Config.ARGB_); } }
布局文件
<LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="dp" android:layout_marginTop="dp" > <TextView android:id="@id/tv_main_msg" android:layout_width="dp" android:layout_height="dp" android:background="@android:color/holo_red_dark" android:gravity="center_vertical|center_horizontal" android:text="你没中奖" android:textSize="sp" /> <com.example.guale.EraseView android:id="@id/eraseView1" android:layout_width="dp" android:layout_height="dp" /> </RelativeLayout></LinearLayout>
Android or Linux 的休眠与唤醒 转载自:
Android 图片轮播 图片轮播的大部分功能,可点击,可手势滑动,自动播放,无限循环播放,加载网络资源,动态添加数量效果图:感兴趣的关注一下微信订阅号爱开发:
GitHub Android 开源项目汇总 本文转载自IT-Homer的博客GitHubAndroid开源项目汇总分类:Android--:人阅读评论()收藏举报GitHub上的开源项目不胜枚举,越来越多的开源项目正
标签: 刮刮奖软件下载
本文链接地址:https://www.jiuchutong.com/biancheng/384251.html 转载请保留说明!上一篇:解决android sdk manager 无法更新问题【亲测】(解决android 11+的保存文件路径问题)
友情链接: 武汉网站建设