仿蜻蜓FM轮播banner

Overview

QingtingBannerView

仿蜻蜓FM轮播banner

Android Arsenal

What's QingtingBannerView ?

A simple banner has infinite loop and animated line.

Demo

效果

Feature

  • Infinite loop
  • Animated line in bottom
  • Auto scroll

Import

Add it in your project's build.gradle at the end of repositories:

repositories {
    maven {
        url 'https://dl.bintray.com/wangyuwei/maven'
    }
}

Step 2. Add the dependency in the form

dependencies {
  compile 'me.wangyuwei:banner:1.0.9'
}

Usage

Step 1 : Define your banner under your xml :

    <me.wangyuwei.banner.BannerView
        android:id="@+id/banner_view"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        qt:qt_line_color="#688fdb" />

Step 2 : Initialize banner data :

    List<BannerEntity> entities = new ArrayList<>();

Step 3 : set banner data :

    mBannerView.setEntities(entities);

Step 4 : set banner click listener :

    mBannerView.setOnBannerClickListener(new OnBannerClickListener() {
                @Override
                public void onClick(int position) {
                    Toast.makeText(MainActivity.this, position + "=> " + entities.get(position).title, Toast.LENGTH_SHORT).show();
                }
            });

Use auto scroll(Optional)

    @Override
    public void onStart() {
        super.onStart();
        mBannerView.startAutoScroll();
    }

    @Override
    public void onStop() {
        mBannerView.stopAutoScroll();
        super.onStop();
    }

##License

Copyright 2016 JeasonWong

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.
You might also like...
Comments
  • 请教回调方法中的判断逻辑代码

    请教回调方法中的判断逻辑代码

    你好 请问一下回调方法中 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { bannerLine.setPageScrolled(position, positionOffset); if (positionOffsetPixels == 0.0) { if (position == entities.size() - 1) { bannerViewPager.setCurrentItem(1, false); } else if (position == 0) { bannerViewPager.setCurrentItem(entities.size() - 2, false); } else { bannerViewPager.setCurrentItem(position); } } }

    else if (position == 0) { bannerViewPager.setCurrentItem(entities.size() - 2, false); }

    删除这个判断代码,运行效果好像没看出不同呢,请指教~

    opened by ZackLee 2
  • How To Use on Click/Touch Listener With It??

    How To Use on Click/Touch Listener With It??

    How can i use onClickListener or onTouchListener with BannerView??? I have tried using the following but it only works for the first TextView

    final TextView tv = (TextView) mBannerView.findViewById(R.id.tv_banner_title);
                            tv.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Toast.makeText(activity.getApplicationContext(), tv.getText(), Toast.LENGTH_SHORT).show();
                                }
                            });
    
    opened by syedalinaqi 1
  • Duplicate auto scroll function

    Duplicate auto scroll function

    Hi @JeasonWong From the last commit i see you merged https://github.com/JeasonWong/QingtingBannerView/tree/MikeCoder-master to master branch. I see that it has auto scroll function under development. I think you must review it again, since from my last commit, i already implemented auto scroll function. And i think mine is simpler and easy to use with function to stop auto scroll directly to comply Activity lifecycle(onStop), so it will avoid Activity leak

    opened by hendrawd 0
Owner
巴掌
巴掌