# WaveSideBar **Repository Path**: HarmonyOS-tpc/WaveSideBar ## Basic Information - **Project Name**: WaveSideBar - **Description**: 带有波浪效果的索引侧栏 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-04-01 - **Last Updated**: 2025-02-06 ## Categories & Tags **Categories**: harmonyos-listview **Tags**: None ## README # WaveSideBar ## 目录 * [功能介绍](#功能介绍) * [演示](#演示) * [集成](#集成) * [布局文件](#布局文件) * [自定义属性说明](#自定义属性说明) * [接口说明](#接口说明) ## 功能介绍 - [x] 带有波浪效果的索引侧栏 ## 演示 |左侧滑动 | 右侧滑动| |:---:|:---:| ||| |自定义索引 | |:---:| || ## 集成 ``` 添加wavesidebar.har到entry下的libs文件夹内 将项目中的build.gradle文件中dependencies→classpath版本改为对应的版本(即你的IDE新建项目中所用的版本) entry的build.gradle内添加如下代码 implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) 方式二: allprojects{ repositories{ mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:WaveSideBar:1.0.3' ``` ## 布局文件 ```xml ``` ``` WaveSideBar sideBar = (WaveSideBar) findComponentById(ResourceTable.Id_side_bar); sideBar.setPosition(WaveSideBar.POSITION_LEFT); sideBar.setTextColor(Color.BLACK); sideBar.setMaxOffset(100); sideBar.setPosition(WaveSideBar.POSITION_LEFT); sideBar.setTextAlign(WaveSideBar.TEXT_ALIGN_CENTER); sideBar.setLazyRespond(true); sideBar.setOnSelectIndexItemListener(new WaveSideBar.OnSelectIndexItemListener() { @Override public void onSelectIndexItem(String index) { } }); ``` ## 自定义属性说明 属性名 | 说明 | 默认值 :----------- | :----------- | :----------- WaveSideBar_sidebar_text_color | 侧栏的文字颜色。 | Color.BLACK WaveSideBar_sidebar_lazy_respond | 是否懒加载。 | false WaveSideBar_sidebar_text_size | 文字尺寸。 | 14vp WaveSideBar_sidebar_max_offset | 当前选中索引项的偏移量 | 100vp WaveSideBar_sidebar_position | 侧栏位置 | POSITION_RIGHT WaveSideBar_sidebar_text_alignment | 项的对齐方式 | TEXT_ALIGN_CENTER ## 接口说明 ```java /** *自定义侧边栏的文字内容 * * @param indexItems 文字 */ public void setIndexItems(String... indexItems) /** *设置侧边栏文字颜色 * * @param color 文字颜色 */ public void setTextColor(Color color) /** *侧栏位置 * * @param position 侧栏位置 */ public void setPosition(int position) /** *当前选中索引项的偏移量 * * @param offset 偏移量 */ public void setMaxOffset(int offset) /** *如果为true,则直到手指抬起时,才会调用侦听器。如果false调用时,手指向下,移动和向上 * * @param lazyRespond 是否懒加载 */ public void setLazyRespond(boolean lazyRespond) /** *项的对齐方式 * * @param align 项的对齐方式 */ public void setTextAlign(int align) /** *设置侧边栏文字大小 * * @param size 文字大小 */ public void setTextSize(float size) ``` ## License MIT License Copyright (c) 2016 郭佳哲 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.