左侧滑动 | 右侧滑动 |
---|---|
自定义索引 |
---|
添加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'
<com.gjiazhe.sidebar.WaveSideBar
ohos:id="$+id:side_bar"
ohos:width="match_parent"
ohos:height="match_parent"
ohos:right_padding="8vp"
ohos:left_padding="8vp"/>
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 |
/**
*自定义侧边栏的文字内容
*
* @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)
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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型