# StickerView **Repository Path**: chinasoft4_ohos/StickerView ## Basic Information - **Project Name**: StickerView - **Description**: 一个可以添加贴纸和缩放、拖动、翻转、删除它的视图 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 1 - **Created**: 2021-07-16 - **Last Updated**: 2025-02-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # StickerView #### 项目介绍 - 项目名称:StickerView - 所属系列:openharmony的第三方组件适配移植 - 功能:一个可以添加贴纸和缩放、拖动、翻转、删除它的视图。 - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio 2.2 Beta1 - 基线版本:master分支 #### 效果演示 #### 安装教程 1.在项目根目录下的build.gradle文件中, ``` allprojects { repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } } ``` 2.在entry模块的build.gradle文件中, ``` dependencies { implementation('com.gitee.chinasoft_ohos:StickerView:1.0.0') ...... } ``` 在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 布局文件定义,提供控件:StickerView 添加图片贴图 PixelMap pixelMap = PixelMapFactoryUtil.getPixelMapFromResource(getContext(), ResourceTable.Media_haizewang_23, new ImageSource.DecodingOptions()); Element drawable = new PixelMapElement(pixelMap); // 添加addSticker stickerView.addSticker(new DrawableSticker(drawable)); // 添加addSticker, 第二个参数为设置显示位置 stickerView.addSticker(new DrawableSticker(drawable), Sticker.Position.BOTTOM | Sticker.Position.RIGHT); 添加文字贴图 stickerView.addSticker( new TextSticker(getApplicationContext()) .setDrawable(bubble) //设置文字背景图 .setText("Sticker\n") //设置文字内容 .setMaxTextSize(14) //设置最大Text大小值 .resizeText() , Sticker.Position.TOP); 替换Sticker使用的方法 stickerView.replace(sticker); stickerView.invalidate(); 删除单个贴图 stickerView.removeCurrentSticker() 删除所有贴图 stickerView.removeAllStickers(); 设置是否锁定贴图 stickerView.setLocked(!stickerView.isLocked()) 自定义StickerView控件,可以添加自定义属性,具体可用属性如下: | name | type | info | |-------------------------|-----------|--------------------------------------------------------| | showIcons | boolean | 设置是否显示图标 | | showBorder | boolean | 设置是否显示边框 | | bringToFrontCurrentSticker | boolean | true时把当前贴纸带到前面默认为false | | borderColor | Color | 设置边框的颜色 | | borderAlpha | Float | 设置边框的透明度 | #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.0 #### 版权和许可信息 Copyright 2016 wuapnjie 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.