# TSnackBar **Repository Path**: chinasoft5_ohos/TSnackBar ## Basic Information - **Project Name**: TSnackBar - **Description**: Show a Snackbar from the top. - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://gitee.com/chinasoft5_ohos/TSnackBar - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-07-21 - **Last Updated**: 2021-10-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TSnackbar #### 项目介绍 - 项目名称:TSnackBar - 所属系列:openharmony的第三方组件适配移植 - 功能:Show a Snackbar from the top. - 项目移植状态:主功能完成 - 调用差异:无 - 开发版本:sdk6,DevEco Studio2.2 Beta1 - 基线版本:Release V2.0.0 #### 效果演示 ![效果演示](./sample/sample.gif) #### 安装教程 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:TSnackBar:1.0.0') ...... } ``` 在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 简单使用 ``` java TSnackbar.make(findComponentById(ResourceTable.Id_dependentLayout),"Hello from TSnackBar.",TSnackbar.LENGTH_LONG).show(); ``` 自定义颜色 ``` java TSnackbar snackbar = TSnackbar.make(findComponentById(ResourceTable.Id_dependentLayout), "A Snackbar is a lightweight material design method for providing feedback to a user, while optionally providing an action to the user.", TSnackbar.LENGTH_LONG); snackbar.setActionTextColor(ResourceTable.Color_blue); View snackbarView = snackbar.getView(); ShapeElement background = new ShapeElement(); background.setRgbColor(RgbColor.fromRgbaInt(Color.getIntColor("#CC00CCFF"))); snackbarView.setBackground(background); Text textView = (Text) snackbarView.findComponentById(ResourceTable.Id_snackbar_text); textView.setTextColor(Color.YELLOW); snackbar.show(); ``` 设置图标 ``` java // vectordrawable TSnackbar snackbar = TSnackbar .make(relative_layout_main, "Snacking with VectorDrawable", TSnackbar.LENGTH_LONG); snackbar.setActionTextColor(ResourceTable.Color_white); snackbar.setIconLeft(ResourceTable.Media_ic_core, 24); View snackbarView = snackbar.getView(); ShapeElement background = new ShapeElement(); background.setRgbColor(RgbColor.fromRgbaInt(Color.getIntColor("#CC00CCFF"))); snackbarView.setBackground(background); Text textView = (Text) snackbarView.findComponentById(ResourceTable.Id_snackbar_text); textView.setTextColor(Color.YELLOW); snackbar.show(); // left and right icon TSnackbar snackbar = TSnackbar .make(relative_layout_main, "Snacking Left & Right", TSnackbar.LENGTH_LONG); snackbar.setActionTextColor(Color.WHITE); snackbar.setIconLeft(ResourceTable.Media_ic_core, 24); //Size in dp - 24 is great! snackbar.setIconRight(ResourceTable.Media_icon, 48); //Resize to bigger dp snackbar.setIconPadding(8); snackbar.setMaxWidth(3000); //if you want fullsize on tablets View snackbarView = snackbar.getView(); ShapeElement background = new ShapeElement(); background.setRgbColor(RgbColor.fromRgbaInt(Color.getIntColor("#CC00CCFF"))); snackbarView.setBackground(background); Text textView = (Text) snackbarView.findComponentById(ResourceTable.Id_snackbar_text); textView.setTextColor(Color.YELLOW); snackbar.show(); ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.0 - 0.0.1-SNAPSHOT #### 版权和许可信息 ~~~~ Copyright 2015 AndroidAdvance.com 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. ~~~~