在moudle级别下的build.gradle文件中添加依赖,在dependencies标签中增加对libs目录下jar包的引用
// 添加maven仓库
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
// 添加依赖库
dependencies {
implementation 'com.gitee.chinasoft_ohos:fastscroll:1.0.0'
}
在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
在 layout 文件:
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/apk/res-auto"
ohos:height="match_parent"
ohos:width="match_parent"
>
<ListContainer
ohos:id="$+id:list_con"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical"
></ListContainer>
<com.futuremind.recyclerviewfastscroll.FastScroller
ohos:id="$+id:fast"
ohos:height="match_parent"
ohos:width="match_content"
ohos:align_parent_right="true"
ohos:orientation="vertical"
>
</com.futuremind.recyclerviewfastscroll.FastScroller>
</DependentLayout>
在 Ability/AbilitySlice:
listContainer = (ListContainer) mainComponent.findComponentById(ResourceTable.Id_list_con);
fastScroller = (FastScroller) mainComponent.findComponentById(ResourceTable.Id_fast);
listContainer.setItemProvider(BaseItemProvider);
//必须在 listContainer.setItemProvider之后调用
fastScroller.setListContainer(listContainer);
在 ListContainer.BaseItemProvider
public class BaseItemProvider ... implements SectionTitleProvider{
...
@Override
public String getSectionTitle(int position) {
//此字符串将显示在指定位置的冒泡中
return getItem(position).substring(0, 1);
}
}
注意: 您必须在适配器中填充足够的项目,以便“FastScroll”显示。我有一个自动隐藏机制,以防没有东西可以滚动。
水平方向
您可以将此库与水平LayoutManager一起使用。使用ohos:orientation="horizontal"属性:
<com.futuremind.recyclerviewfastscroll.FastScroller
ohos:id="$+id:fast"
ohos:height="match_parent"
ohos:width="match_content"
ohos:orientation="vertical"
>
</com.futuremind.recyclerviewfastscroll.FastScroller>
样式
在0.1.5版中引入了样式化,并提供了一组有限的可样式化属性。更多的项目正在进行中。更多的项目正在进行中。
你可以在xml布局中样式属性:
相关属性:
<com.futuremind.recyclerviewfastscroll.FastScroller
...
app:handleColor="#8f93d1"
app:bubbleColor="#5e64ce"
app:bubbleTextColor="#e0e0e0"
app:bubbleTextSize="24fp"
app:textStyle="bold"
/>
或直接在代码中:
fastScroller.setBubbleColor(0xffff0000);
fastScroller.setHandleColor(0xffff0000);
fastScroller.setBubbleTextColor(0xffff0000);
fastScroller.setBubbleTextSize(24);
fastScroller.setTextStyle("bold");
更多信息请参见示例代码。
自定义控件
你可以为你的滚动条和气泡设置自定义布局和动画,使用:
myViewProvider = new CustomScrollerViewProvider();
fastScroller.setViewProvider(myViewProvider);
要了解更多信息,请查看 CustomScrollerViewProvider
示例代码.
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
Copyright 2015 Future Mind
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.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )