回复
鸿蒙开源组件——轮播图自定义组件
jacksky
发布于 2022-2-21 17:58
浏览
0收藏
Ohos-Coverflow
项目介绍
- 项目名称:Ohos-Coverflow
- 所属系列:openharmony第三方组件适配移植
- 功能:轮播图自定义组件
- 项目移植状态:主功能未完成
- 调用差异:有
ohos缺少相应无法实现一页三张功能 - 开发版本:sdk6,DevEco Studio2.2 Beta1
- 基线版本:Release -1.0.5
效果演示
安装教程
1.在moudle级别下的build.gradle文件中添加依赖,在dependencies标签中增加对libs目录下jar包的引用
// 添加maven仓库
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/release/'
}
}
// 添加依赖库
dependencies {
implementation 'com.gitee.chinasoft_ohos:coverflow:1.0.0'
}
在sdk6,DevEco Studio2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
使用说明
- xml属性单个可滑动的页面
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
>
<DependentLayout
ohos:height="250vp"
ohos:background_element="$color:color_black"
ohos:width="match_parent">
<PageSlider
ohos:center_in_parent="true"
ohos:margin="30vp"
ohos:layout_alignment="center"
ohos:height="230vp"
ohos:id="$+id:ViewPageSlider"
ohos:width="match_parent"/>
</DependentLayout>
</DirectionalLayout>
- xml 自定义ListContainer下拉滑动时的滑动条
<com.futuremind.recyclerviewfastscroll.FastScroller ohos:id="$+id:fast" ohos:height="match_parent" ohos:width="match_content" ohos:align_parent_right="true" app:handleColor="#8f93d1" app:bubbleColor="#5e64ce" app:bubbleTextColor="#e0e0e0" app:bubbleTextSize="24fp" app:bubbleTextWeight="700" ohos:orientation="vertical" />
- Java 调用示例
ListContainer下拉时加入的竖线
listContainer = (ListContainer) findComponentById(ResourceTable.Id_listcontainerview);
fastScroller = (FastScroller)findComponentById(ResourceTable.Id_fast);
fastScroller.setListContainer(listContainer);
两个平滑页面的适配器,在onPageChosen方法进行设置进行联动
PagerContainerOne.OnSelectListener onSelectListener1 = new PagerContainerOne.OnSelectListener() {
@Override
public void select(int index) {
pageslider1.setCurrpage(index);
textView.setText(item + index);
pageslider2.setCurrpage(index);
textView2.setText(item + index);
}
};
pageslider1.setPageChangeListener(onSelectListener1);
PagerContainerOne.OnSelectListener onSelectListener2 = new PagerContainerOne.OnSelectListener() {
@Override
public void select(int index) {
pageslider1.setCurrpage(index);
textView.setText(item + index);
pageslider2.setCurrpage(index);
textView2.setText(item + index);
}
};
pageslider2.setPageChangeListener(onSelectListener2);
定义回调方法将当前页面回调出去
public interface OnSelectListener {
/**
* 回调当前的页数
*
* @param index
*/
void select(int index);
}
在外部回调的方法
/**
* 设置外部进行回调方法
*
* @param listener
*/
public void setPageChangeListener(OnSelectListener listener) {
this.mListener = listener;
}
测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本有差异
因ohos缺少相应的接口无法实现一页三张功能
版本迭代
- 1.0.1
版权和许可信息
The MIT License (MIT)
Copyright (c) 2015 Hugo yu
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.
Status API Training Shop Blog About Pricing
ohos-Coverflow-master.zip 4.64M 4次下载
已于2022-2-21 17:58:40修改
赞
收藏
回复
相关推荐