• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Java
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

自定义无限轮转控件

Loop View for Android

English 中文

Android LoopView is a powerful widget for unlimited rotation picture, It provides some configuration options and good control the appearance and operational requirements.

Simple usage picture:
AdLoopView Simple Demo

Custom layout usage picture:
AdLoopView Demo

Using LoopView in your application

If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:

androidX

implementation 'com.zwenkai:loopview:2.0.1'

support

implementation 'com.kevin:loopview:1.5.6'

Simple Usage

Configured as View in layout.xml

To add the LoopView to your application, specify <com.kevin.loopview.BannerView in your layout XML.

<com.kevin.loopview.BannerView
    android:id="@+id/main_act_banner"
    android:layout_width="match_parent"
    android:layout_height="192dp">
</com.kevin.loopview.BannerView>

Configured Programmatically

BannerView mBannerView = (BannerView) this.findViewById(R.id.main_act_banner);
// set image loader, can set up any image engine.
mBannerView.setImageLoader(new ImageLoader() {
    @Override
    public void loadImage(ImageView imageView, String url, int placeholder) {
        Glide.with(imageView.getContext()).load(url).into(imageView);
    }
});
String json = LocalFileUtils.getStringFormAsset(this, "loopview_date.json");
LoopData loopData = new Gson().fromJson(json, LoopData.class);
mBannerView.setData(loopData);
// begin to loop
mBannerView.startAutoLoop();

mBannerView.setOnItemClickListener(new BaseLoopAdapter.OnItemClickListener() {
    @Override
    public void onItemClick(View view, LoopData.ItemData itemData, int position) {
        // Open connection with browser
        Intent intent = new Intent();
        intent.setData(Uri.parse(itemData.link));
        intent.setAction(Intent.ACTION_VIEW);
        startActivity(intent);
    }
});

More configuration Usage

XML Usage

If you decide to use BannerView as a view, you can define it in your xml layout like this:

xmlns:app="http://schemas.android.com/apk/res-auto"

<com.kevin.loopview.BannerView
    android:id="@+id/adloop_act_adloopview"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    app:loop_interval="5000"
    app:loop_scrollDuration="2000"
    app:loop_dotMargin="5dp"
    app:loop_autoLoop="[true|false]"
    app:loop_alwaysShowDot="[true|false]"
    app:loop_dotSelector="@drawable/ad_dots_selector"
    app:loop_placeholder="@mipmap/ic_launcher"
    app:loop_layout="@layout/ad_loopview_layout">
</com.kevin.loopview.BannerView>

Programme Usage

// Set page switching transition time
mLoopView.setScrollDuration(1000);
// Set time interval
mLoopView.setInterval(3000);
// To initialize the data in a collection
mLoopView.setData(List<Map<String, String>> data);
// Initialized data in entity mode
mLoopView.setData(LoopData rotateData);
// Initialized data in a collection mode
mLoopView.setData(List<String> images);
// Initialized data in a collection mode
mLoopView.setData(List<String> images, List<String> links);
// Initialized data in a collection mode
mLoopView.setData(List<String> images, List<String> descs, List<String> links);
// Get the running loop date
mLoopView.getData();
// Begin to auto Loop
mLoopView.startAutoLoop();
// Begin to auto Loop delay
mLoopView.startAutoLoop(long delayTimeInMills);
// Stop to auto Loop
mLoopView.stopAutoLoop();
// Set a custom loop layout
mLoopView.setLoopLayout(int layoutResId);

Notes:

In custom layout you must to use those ids loop_view_pager in ViewPager loop_view_dots in indicate point parent LinearLayout and loop_view_desc in description TextView;

Make sure you at least have loop_view_pager.

License

Copyright 2015 Kevin zhou

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.

More Repositories

1

DelegationAdapter

一种优雅的方式来使用RecyclerView
Kotlin
413
star
2

PullToRefresh-Demo

Demos of PullToRefresh.
Java
137
star
3

Android-ImageCrop

Android image crop
Java
97
star
4

WrapRecyclerView

RecyclerView can add header and footer.
Java
92
star
5

Android-TabIndicator

底部导航
Java
82
star
6

Android-Crop

Java
77
star
7

Android-JSONTool

JSON Bean 相互转换
Java
45
star
8

ImageUpload

Android上传图片到JavaWeb服务器
Java
42
star
9

UltimateRecyclerView

RecyclerView that support pull to refresh,add header and footer.
Java
27
star
10

SlidingTabLayout

Java
18
star
11

Android-ShadowView

Android Shadow View
Java
15
star
12

Android-WheelView

Kotlin
12
star
13

Android-BaseDialog

基于DialogFragment的弹窗封装,使弹窗使用更简单。
Kotlin
8
star
14

Android-GridPagerView

让网格翻页开发变得更简单
Kotlin
8
star
15

Ksoup

优雅地把Html解析为Java/Kotlin实体对象
HTML
6
star
16

Android-Utils

Android 常用工具类
Java
5
star
17

Android-ScaleHelper

Android 屏幕适配的一种方案
Java
4
star
18

Android-WhiteListTool

Android 启动白名单工具
Kotlin
4
star
19

Hannibai

A easy way to use android SharePreference.
Java
3
star
20

VlayoutHelper

vlayout & databinding & MVVM
Java
3
star
21

RemoteBuild

远程编译项目
Shell
3
star
22

Android-ViewContext

扩展Fragment、Activity方便获取Context、Activity、LifecycleOwner、Resources
Kotlin
2
star
23

Android-WebShareInfo

获取WebView中H5的分享(开放图谱)信息
Kotlin
2
star
24

SupperTextView

Java
1
star
25

SwipeToLoadLayout

Kotlin
1
star
26

Android-KnowledgeGraph

Android 知识点归纳总结
1
star
27

Android-GitHubAppDownload

官方GitHub App下载,给不方便翻墙的童鞋~
1
star