一个Android的简单刮刮卡效果视图
kenrry1992 · 1232浏览量 · 发布于2019-06-03
作者skymansandy,源码scratchCardLayout。受Google Pay,PhonePe和Zomato奖励系统启发的一种简单Android刮刮卡效果视图。
特征:
刮刮卡效果到任何视图。
用ScratchCardLayout包装现有的复杂布局。
基于CardView的库。 所以CardView的所有样式都可用。
设置划痕画笔宽度。
启用/禁用划痕效果
将Drawable设置为划痕(颜色/图像)。
应该显示完整布局时设置划痕的百分比。
抓挠开始,进展(百分比)和停止时获取回调。
演示
用法
相关性:
dependencies { implementation 'in.codeshuffle.scratchcardlayout:ScratchCardLayout:1.0.6' }
XML用法
<in.codeshuffle.scratchcardview.ui.ScratchCardLayout android:id="@+id/scratchCard" android:layout_width="250dp" android:layout_height="250dp" android:layout_centerInParent="true" app:scratchWidth="40dp" app:scratchEnabled="true" app:scratchDrawable="@drawable/your_drawable" app:scratchRevealFullAtPercent="100"> <!--Your complex view here--> </in.codeshuffle.scratchcardview.ui.ScratchCardLayout>
Java 用法
//Get view reference ScratchCardLayout scratchCardLayout = findViewById(R.id.scratchCard); //Set the drawable (programmatically) scratchCardLayout.setScratchDrawable(getResources().getDrawable(R.drawable.car)); //Set scratch brush width scratchCardLayout.setScratchWidth(30f); //Reveal full layout when some percent of the view is scratched scratchCardLayout.setRevealFullAtPercent(40); //Scratching enable/disable scratchCardLayout.setScratchEnabled(true); //Remove all scratch made till now scratchCardLayout.resetScratch();
监视可用
实现给定的接口并覆盖这些东西:
//Implement this to your class yourClass extends someBaseClass implements ScratchListener //Set the listener scratchCardLayout.setScratchListener(this); //You'll have three main callback methods as scratch listeners //Scratch started void onScratchStarted(); //Scracth progress (NOTE: not guaranteed to be exact percent. consider it like atleast this much percent has been scratched) void onScratchProgress(ScratchCardLayout scratchCardLayout, int atLeastScratchedPercent); //Scratch completed void onScratchComplete();
PlayStore 应用
https://play.google.com/store/apps/details?id=in.codeshuffle.scratchcardlayoutexample
注意
- The progress is the value guaranteeing that the mentioned percent is atleast scratched. NOT THE EXACT PERCENTAGE (for performance reasaons)
源码使用过程中,如无法搭建或有增加其他功能需求,可联系QQ:236-0248-666 ,付费搭建安装修改服务!
温馨提示:网站源码只作为学习或研究使用,如需商业使用请购买正版!
温馨提示:网站源码只作为学习或研究使用,如需商业使用请购买正版!
相关推荐
Android卡片效果源码
相关信息
kenrry1992 · 653浏览 · 2019-12-04 16:40:11
android模仿微信朋友圈效果源码
相关信息
kenrry1992 · 670浏览 · 2019-12-04 15:25:43
安卓视图效果 一个转动的效果和一个3D触摸效果
相关信息
kenrry1992 · 537浏览 · 2019-11-05 11:29:23
渐变颜色渐变文字渐变图像 安卓源码
相关信息
冷月葬花魂 · 859浏览 · 2019-10-31 17:32:07
一个可以解析图片颜色,还可以为图片设置多彩阴影控件 安卓源码
相关信息
冷月葬花魂 · 609浏览 · 2019-10-09 10:21:40
安卓仿支付宝首页下拉刷新视图效果源码
相关信息
kenrry1992 · 945浏览 · 2019-10-09 09:44:58
Android一个可以上拉下滑的Ui效果
相关信息
kenrry1992 · 706浏览 · 2019-10-09 09:38:36
分类专栏
最新发布
源码排行榜
0评论