5 Star 6 Fork 2

HarmonyOS-TPC/MZBannerView

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0
# MZBannerView 仿魅族BannerView,图片轮播控件,支持多种模式切换:普通ViewPager使用,普通Banner使用,仿魅族Banner使用。 ## 概述 * 支持本地图片和网络图片轮播 * 不支持仿魅族的轮播左右边界样式 ## 演示 <img src="screenshot/mzbanner.gif" width="75%"/> ## 集成 ``` 方式一: 通过library生成har包,添加har包到libs文件夹内 在entry的gradle内添加如下代码 implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) 方式二: allprojects{ repositories{ mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:MZBannerView:1.0.0' ``` ## entry运行要求 通过DevEco studio,并下载SDK 将项目中的build.gradle文件中dependencies→classpath版本改为对应的版本(即你的IDE新建项目中所用的版本) ## 示例 ```xml <?xml version="1.0" encoding="utf-8"?> <DirectionalLayout xmlns:ohos="http://schemas.huawei.com/res/ohos" xmlns:app="http://schemas.huawei.com/res/app" ohos:width="match_parent" ohos:height="match_parent" ohos:orientation="vertical"> <Text ohos:width="match_parent" ohos:height="match_content" ohos:text_color="#aaa" ohos:text_size="20vp" ohos:text="仿魅族Banner网络版" ohos:text_alignment="center" /> <com.zhouwei.mzbanner.MZBannerView ohos:id="$+id:banner" ohos:width="match_parent" ohos:height="160vp" ohos:top_margin="10vp" app:open_mz_mode="true" app:canLoop="true" app:middle_page_cover="true" app:indicatorAlign="center" app:indicatorPaddingLeft="10vp" app:indicatorPaddingBottom="50vp" /> <Text ohos:width="match_parent" ohos:height="match_content" ohos:text_color="#aaa" ohos:text_size="20fp" ohos:text="普通Banner网络版" ohos:text_alignment="center" ohos:top_margin="20vp" /> <com.zhouwei.mzbanner.MZBannerView ohos:id="$+id:banner_normal" ohos:width="match_parent" ohos:height="200vp" ohos:top_margin="10vp" app:open_mz_mode="false" app:canLoop="true" app:indicatorAlign="center" /> </DirectionalLayout> ``` ```java public class NetImagesAbilitySlice extends AbilitySlice { private MZBannerView mMZBanner; private MZBannerView mNormalBanner; private static String []imagesMZ={ "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2F725c03f7f1c7346291e8a4b7187e2b7ad762fd3c.jpg&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=22500bdcab3b90b7a7ee38330acecb34", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.wallcoo.com%2Fnature%2F2009_Landscape_1680_Desktop_03%2Fwallpapers%2F1280x1024%2FAgricultural%2520Fields%2520and%2520Village%2520Tibet.jpg&refer=http%3A%2F%2Fwww.wallcoo.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=38ec6713b22d2f9a903da65d608a51e6", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg2.3lian.com%2F2014%2Ff5%2F11%2Fd%2F51.jpg&refer=http%3A%2F%2Fimg2.3lian.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=3620fb9390585ac6d01e8fc4821bd207", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20190623%2F22%2F1561298984-bAuNFdmJok.jpg&refer=http%3A%2F%2Fimage.biaobaiju.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=434ac89dac1e857e907cd391720d3945", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.wallcoo.com%2Fnature%2F2009_Landscape_1680_Desktop_03%2Fwallpapers%2F1680x1050%2FWild%2520Goose%2520Island%2520on%2520Saint%2520Mary%2520Lake%2520at%2520Sunrise%2520Glacier%2520National%2520Park%2520Montana.jpg&refer=http%3A%2F%2Fwww.wallcoo.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=77b1b665fbd7ebb89fca615ef87ef68d", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.pconline.com.cn%2Fimages%2Fupload%2Fupc%2Ftx%2Fphotoblog%2F1206%2F13%2Fc12%2F11988648_11988648_1339594072859.jpg&refer=http%3A%2F%2Fimg.pconline.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613116329&t=f3c9bc53d5acb774cb2dccde74390d77", }; @Override public void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_net_main); mMZBanner = (MZBannerView)findComponentById(ResourceTable.Id_banner); mMZBanner.setBannerPageClickListener((view, position) -> { }); mMZBanner.addPageChangeListener(new PageSlider.PageChangedListener() { @Override public void onPageSliding(int i, float v, int i1) { } @Override public void onPageSlideStateChanged(int i) { } @Override public void onPageChosen(int i) { } }); List<String> nomalbannerlist = new ArrayList<>(); for(int i=0;i<imagesMZ.length;i++){ nomalbannerlist.add(imagesMZ[i]); } List<String> mzbannerList = new ArrayList<>(); for(int i=0;i<imagesMZ.length;i++){ mzbannerList.add(imagesMZ[i]); } mMZBanner.setIndicatorVisible(true); // 代码中更改indicator 的位置 //mMZBanner.setIndicatorAlign(MZBannerView.IndicatorAlign.LEFT); //mMZBanner.setIndicatorPadding(10,0,0,150); mMZBanner.setPages(mzbannerList, new MZHolderCreator<BannerViewHolder>() { @Override public BannerViewHolder createViewHolder() { return new BannerViewHolder(); } }); mNormalBanner = (MZBannerView)findComponentById(ResourceTable.Id_banner_normal); mNormalBanner.setPages(nomalbannerlist, new MZHolderCreator<BannerViewHolder>() { @Override public BannerViewHolder createViewHolder() { return new BannerViewHolder(); } }); mMZBanner.start(); mNormalBanner.start(); } public static class BannerViewHolder implements MZViewHolder<String> { private Image mImageView; private DisplayImageOptions options; @Override public Component createView(Context context) { // 返回页面布局文件 Component view = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_banner_item,null,false); mImageView = (Image) view.findComponentById(ResourceTable.Id_banner_image); options = new DisplayImageOptions.Builder() .showImageOnLoading(ResourceTable.Media_icon) .showImageForEmptyUri(ResourceTable.Media_icon) .showImageOnFail(ResourceTable.Media_icon) .cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .bitmapConfig(PixelFormat.RGB_565) .build(); return view; } @Override public void onBind(Context context, int position, String data) { ImageLoader.getInstance().displayImage(data,mImageView,options,new SimpleImageLoadingListener(){ @Override public void onLoadingComplete(String imageUri, Component view, PixelMap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); } }); } } @Override public void onActive() { super.onActive(); } @Override public void onForeground(Intent intent) { super.onForeground(intent); } } ``` ### License Copyright (C) 2017 zhouwei 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.

简介

仿魅族BannerView,图片轮播控件 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HarmonyOS-tpc/MZBannerView.git
[email protected]:HarmonyOS-tpc/MZBannerView.git
HarmonyOS-tpc
MZBannerView
MZBannerView
master

搜索帮助