# Scratch-View **Repository Path**: to-you-too/scratch-view ## Basic Information - **Project Name**: Scratch-View - **Description**: 自定义View,刮刮卡效果 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-24 - **Last Updated**: 2024-11-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ScratchView #### 介绍 主要功能: 自定义刮刮卡效果。 项目从 ScratchView ( https://github.com/D-clock/ScratchView )移植而来 #### 项目介绍 - 项目名称:ScratchView - 编程语言:Java - 所属系列:第三方组件适配移植 - 功能:自定义刮刮卡效果。 - 项目移植状态:完成 - 调用差异:无差异 - 开发版本:sdk5,DevEco Studio2.1 beta3 - 原项目Doc地址:https://github.com/D-clock/ScratchView #### 安装教程 ##### 方式一: - 1.下载har包[scratch_view-1.0.0.har](https://repo.maven.apache.org/maven2/com/gitee/archermind-ti/scratch_view/1.0.0/)。 - 2.启动 DevEco Studio,将下载的har包,导入工程目录“entry->libs”下。 - 3.在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下jar包的引用。 ``` dependencies { implementation fileTree(dir: 'libs', include: ['.jar', '.har']) ... } ``` ##### 方式二: 在project的build.gradle中添加mavenCentral()的引用 ``` repositories { ... mavenCentral() ... } ``` 在entry的build.gradle中添加依赖 ``` dependencies { ... implementation 'com.gitee.archermind-ti:scratch_view:1.0.0' ... } ``` #### 使用说明 1. xml文件中代码 ```xml ``` xml属性 | 描述 ---|--- app:sv_mask_color | 表示蒙板颜色 app:sv_vertical_repeat_count | 表示水印在纵向每列上的个数 app:sv_horizontal_repeat_count | 表示水印在横向每行上的个数 app:sv_max_percent | 表示最大擦除完成比例 app:sv_erase_size | 表示刮刮卡橡皮擦宽度 app:sv_water_mark | 表示水印资源 2. java代码中的API接口 ```java //设置蒙板颜色 scratchView.setMaskColor(0xffff0000); //设置蒙板上水印,参数为-1时,表示无水印 scratchView.setWatermark(ResourceTable.Media_alipay); //清除蒙板 scratchView.clear(); //重置为初始状态 scratchView.reset(); //设置橡皮擦宽度 scratchView.setEraserSize(60); //设置最大擦除比例,取值为0-100 scratchView.setMaxPercent(70); //设置刮刮卡擦除监听器 scratchView.setEraseStatusListener(new ScratchView.EraseStatusListener() { @Override public void onProgress(int percent) {//擦除完成比例 percentView.setText(String.valueOf(percent)); } @Override public void onCompleted(Component component) {//当达到最大擦除比例时,被回调 LogUtil.i("execute onCompleted"); } }); ``` #### 版本迭代 - 1.0.0 #### 版权和许可信息 - Apache Licence ``` Copyright 2016 D_clock爱吃葱花 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```