UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.

Overview

UltraViewPager

中文文档

ProjectUltraViewPager is a ViewPager extension that encapsulates multiple features, mainly to provide a unified solution for multi-page switching scenarios.

Example0 Example1 Example0 Example1

Main Feature

  • support horizontal scrolling and vertical scrolling
  • support multi views in one viewpager
  • support switching views circularly. For example, if there are 3 views to display in a ViewPager, it should switch back to the first view after the third view.
  • support auto-scrolling feature,implemented timer with Handler.
  • support setting max-height and max-width for this ViewPager.
  • support setting the aspect ratio for UltraViewPager.
  • UltraViewPager has a built-in indicator. support circle and icon style.
  • built-in two kind of page tansition animation.

you can combine multiple features at the same time.

Design

UltraViewPager is a super extension for ViewPager. It's actually a RelativeLayout in order to display ViewPager and Indicator.UltraViewPager offers some common method delegate for ViewPager, you can also invoke more method by call getViewPager() and get the actual ViewPager.

In order to achieve vertical scroll, through exchanging MotionEvent in onInterceptTouchEvent and onTouchEvent.For more details, you can read the source code.

Usage

Please find the latest version(1.0.7.7 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories.

Using Gradle:

//gradle
compile ('com.alibaba.android:ultraviewpager:1.0.7.7@aar') {
	transitive = true
}

or grab via Maven:

//pom.xml in maven
<dependency>
  <groupId>com.alibaba.android</groupId>
  <artifactId>ultraviewpager</artifactId>
  <version>1.0.7.7</version>
  <type>aar</type>
</dependency>

Create your own layout using a UltraViewPager:

activity_pager.xml

<com.tmall.ultraviewpager.UltraViewPager
    android:id="@+id/ultra_viewpager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:background="@android:color/darker_gray" />

You can follow my tutorial below on how to use UltraViewPager:

UltraViewPager ultraViewPager = (UltraViewPager)findViewById(R.id.ultra_viewpager);
ultraViewPager.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL);
//initialize UltraPagerAdapter,and add child view to UltraViewPager
PagerAdapter adapter = new UltraPagerAdapter(false);
ultraViewPager.setAdapter(adapter);

//initialize built-in indicator
ultraViewPager.initIndicator();
//set style of indicators
ultraViewPager.getIndicator()
    .setOrientation(UltraViewPager.Orientation.HORIZONTAL)
    .setFocusColor(Color.GREEN)
    .setNormalColor(Color.WHITE)
    .setRadius((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()));
//set the alignment
ultraViewPager.getIndicator().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
//construct built-in indicator, and add it to  UltraViewPager
ultraViewPager.getIndicator().build();

//set an infinite loop
ultraViewPager.setInfiniteLoop(true);
//enable auto-scroll mode
ultraViewPager.setAutoScroll(2000);

For other API reference,see this to read more.

FAQ

  • How to refresh data? you can refresh data by any one below three method:
    • ultraViewPager.refresh();
    • ultraViewPager.getWrapAdapter().notifyDataSetChanged();
    • mViewPager.getViewPager().getAdapter().notifyDataSetChanged();

DEMO

Demo Project

Contributing

Before you open an issue or create a pull request, please read Contributing Guide first.

LICENSE

UltraViewPager is available under the MIT license.

Comments
  • 数据更新后,调用notifyDataSetChanged无效并且异常退出

    数据更新后,调用notifyDataSetChanged无效并且异常退出

    java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 0, found: 1200 Pager id: 1 Pager class: class com.tmall.ultraviewpager.UltraViewPagerView Problematic adapter: class com.tmall.ultraviewpager.UltraViewPagerAdapter at android.support.v4.view.ViewPager.populate(ViewPager.java:1167) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:668) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:630) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:622) at com.tmall.ultraviewpager.UltraViewPagerView.setCurrentItemFake(UltraViewPagerView.java:235) at com.tmall.ultraviewpager.UltraViewPager.scrollNextPage(UltraViewPager.java:360) at com.tmall.ultraviewpager.UltraViewPager$2.callBack(UltraViewPager.java:293) at com.tmall.ultraviewpager.TimerHandler.handleMessage(TimerHandler.java:55) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207)

    compileSdkVersion 25 buildToolsVersion "25.0.2"

    bug 
    opened by zhangxiliang 13
  • Add items after calling setAdapter error:

    Add items after calling setAdapter error: "The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged!"

    The exception:

     java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 0, found: 4 Pager id: 2 Pager class: class com.tmall.ultraviewpager.UltraViewPagerView Problematic adapter: class com.tmall.ultraviewpager.UltraViewPagerAdapter
                                                                                    at android.support.v4.view.ViewPager.populate(ViewPager.java:1135)
                                                                                    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:662)
                                                                                    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:624)
                                                                                    at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:616)
                                                                                    at com.tmall.ultraviewpager.UltraViewPagerView.setCurrentItemFake(UltraViewPagerView.java:242)
                                                                                    at com.tmall.ultraviewpager.UltraViewPager.scrollNextPage(UltraViewPager.java:379)
                                                                                    at com.tmall.ultraviewpager.UltraViewPager$2.callBack(UltraViewPager.java:298)
                                                                                    at com.tmall.ultraviewpager.TimerHandler.handleMessage(TimerHandler.java:61)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                                    at android.os.Looper.loop(Looper.java:164)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    

    Happens when trying to add views after adapter was already created using the following code:

    //The adapter class
    public class MyAdapter extends PagerAdapter {
    
        private Context mContext;
        private List<Object> mData = new ArrayList<>();
    
        public MyAdapter(@NonNull Context context) {
            mContext = context;
        }
    
        @Override
        public int getCount() {
            return mData.size();
        }
    
        // Trying to add data dynamically
        public void addData(@NonNull List<Object> data) {
            mData.addAll(data);
            notifyDataSetChanged();
        }
    
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            RelativeLayout contentContainer = new RelativeLayout(mContext);
            TextView textView = new TextView(mContext);
            textView.setGravity(Gravity.CENTER);
            textView.setText("Content: " + position);
            contentContainer.addView(textView);
            container.addView(contentContainer);
            return contentContainer;
        }
    
        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }
    
        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            if (object instanceof RelativeLayout) {
                RelativeLayout view = (RelativeLayout) object;
                view.removeAllViews();
                container.removeView(view);
            }
        }
    
    // Usage:
    
    // Runs within onCreate()
    UltraViewPager myViewPager = findViewById(R.id.view_pager);
    MyAdapter myAdapter = new MyAdapter(this/*context*/);
    myViewPager.setAdapter(myAdapter); myViewPager.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL);
    myViewPager.setMultiScreen(0.7f);
    myViewPager.setItemRatio(1.0f);
    myViewPager.setAutoScroll(10000);
    myViewPager.setPageTransformer(false, new UltraDepthScaleTransformer());
    
    // Runs after data loaded from server (in the future):
    myAdapter.addData(myData)
    
    
    opened by dimanem 9
  •  java.lang.NullPointerException: Attempt to invoke virtual method 'int com.tmall.ultraviewpager.UltraViewPagerAdapter.getCount()' on a null object reference

    java.lang.NullPointerException: Attempt to invoke virtual method 'int com.tmall.ultraviewpager.UltraViewPagerAdapter.getCount()' on a null object reference

    好像是因为布局文件嵌套太多吗? 尽量减少了布局嵌套就没有这个问题了。,想问下大神。具体的该如何避免这种错误呢,

    java.lang.NullPointerException: Attempt to invoke virtual method 'int com.tmall.ultraviewpager.UltraViewPagerAdapter.getCount()' on a null object reference at com.tmall.ultraviewpager.UltraViewPagerView.getCurrentItem(UltraViewPagerView.java:220) at com.tmall.ultraviewpager.UltraViewPagerView.onMeasurePage(UltraViewPagerView.java:88) at com.tmall.ultraviewpager.UltraViewPagerView.onMeasure(UltraViewPagerView.java:84) at android.view.View.measure(View.java:20171) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462) at com.tmall.ultraviewpager.UltraViewPager.onMeasure(UltraViewPager.java:177) at android.view.View.measure(View.java:20171) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:747) at android.widget.LinearLayout.onMeasure(LinearLayout.java:629) at android.view.View.measure(View.java:20171) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462) at android.view.View.measure(View.java:20171) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6328) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:747) at android.widget.LinearLayout.onMeasure(LinearLayout.java:629) at android.view.View.measure(View.java:20171) at android.support.v7.widget.GridLayoutManager.measureChildWithDecorationsAndMargin(GridLayoutManager.java:724) at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:575) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574) at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17945) at android.view.ViewGroup.layout(ViewGroup.java:5812) at a

    opened by stevin1021 7
  • [寻求帮助]关于刷新无效的问题

    [寻求帮助]关于刷新无效的问题

    Issue 中有很多刷新无效的问题,如 #34 #36 #37 #84 #87 ,我通过 demo 测试无法复现,希望出现问题的同学能简单贴一下使用方式,我的测试代码如下:

    private void defaultUltraViewPager() {
            UltraViewPager ultraViewPager = (UltraViewPager) findViewById(R.id.ultra_viewpager);
            ultraViewPager.setScrollMode(UltraViewPager.ScrollMode.HORIZONTAL);
            //initialize UltraPagerAdapter,and add child view to UltraViewPager
            final UltraPagerAdapter adapter = new UltraPagerAdapter(false);
            ultraViewPager.setAdapter(adapter);
    
            final List<String> strings = new ArrayList<>();
            for (int i = 0; i < 8; i++) {
                strings.add(i + "");
            }
    
            adapter.setData(strings);
    
    
            //set an infinite loop
            ultraViewPager.setInfiniteLoop(true);
    //        enable auto-scroll mode
            ultraViewPager.setAutoScroll(2000);
    
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    List<String> stringList = new ArrayList<String>();
    
                    for (int i = 0; i < 15; i++) {
                        stringList.add(i + "plus");
                    }
                    adapter.setData(stringList);
                    adapter.notifyDataSetChanged();
                }
            }, 5000);
        }
    

    使用此代码替换 demo 中的defaultUltraViewPager方法,并放开 onCreate 里方法调用的注释,同时注释掉下面的一段 switch 。

    help wanted 
    opened by MikeAfc 6
  • UltraViewPagerAdapter.getCount()' on a null object reference

    UltraViewPagerAdapter.getCount()' on a null object reference

    Hi,

    I implemented ultra view pager adapter, i had issues where list has items

    java.lang.NullPointerException: Attempt to invoke virtual method 'int com.tmall.ultraviewpager.UltraViewPagerAdapter.getCount()' on a null object reference at com.tmall.ultraviewpager.UltraViewPagerView.getCurrentItem(UltraViewPagerView.java:217) at com.tmall.ultraviewpager.UltraViewPagerView.onMeasurePage(UltraViewPagerView.java:86) at com.tmall.ultraviewpager.UltraViewPagerView.onMeasure(UltraViewPagerView.java:82) at android.view.View.measure(View.java:19826) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at com.tmall.ultraviewpager.UltraViewPager.onMeasure(UltraViewPager.java:179) at android.view.View.measure(View.java:19826) at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934) at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973) at android.view.View.measure(View.java:19826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6164) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6164) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6164) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19826) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6164) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.CardView.onMeasure(CardView.java:219) at android.view.View.measure(View.java:19826) at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:934) at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:973) at android.view.View.measure(View.java:19826) at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:8765) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1582) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1166) at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:851) at android.support.design.widget.ViewOffsetBehavior.layoutChild(ViewOffsetBehavior.java:63) at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:136) at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42) 03-14 12:29:50.359 29525-29525/com.ebiz.liftptich E/AndroidRuntime: at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361) at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:869) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:755) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5656) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2422) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2142) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1299) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6558) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871) at android.view.Choreographer.doCallbacks(Choreographer.java:683) at android.view.Choreographer.doFrame(Choreographer.java:619) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6316) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

    opened by prasad456 6
  • Messed up

    Messed up

    #35 #32 This is the error =

    08-27 13:54:30.003 11262-11262/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                       Process: ir.agcom.mylitener, PID: 11262
                                                       java.lang.NullPointerException: Attempt to invoke virtual method 'int com.tmall.ultraviewpager.UltraViewPagerAdapter.getCount()' on a null object reference
                                                           at com.tmall.ultraviewpager.UltraViewPagerView.getCurrentItem(UltraViewPagerView.java:217)
                                                           at com.tmall.ultraviewpager.UltraViewPagerView.onMeasurePage(UltraViewPagerView.java:86)
                                                           at com.tmall.ultraviewpager.UltraViewPagerView.onMeasure(UltraViewPagerView.java:82)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
                                                           at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
                                                           at com.tmall.ultraviewpager.UltraViewPager.onMeasure(UltraViewPager.java:179)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1028)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                           at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                           at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                           at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                           at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                           at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                           at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                           at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                           at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                           at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                           at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
                                                           at android.view.View.measure(View.java:17547)
                                                           at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2015)
                                                           at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1173)
                                                           at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1379)
                                                           at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
                                                           at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
                                                           at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                           at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                           at android.view.Choreographer.doFrame(Choreographer.java:550)
                                                           at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                           at android.os.Handler.handleCallback(Handler.java:739)
                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                           at android.os.Looper.loop(Looper.java:135)
                                                           at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                           at java.lang.reflect.Method.invoke(Method.java:372)
                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    
    

    and this is my layout =

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <com.tmall.ultraviewpager.UltraViewPager android:id="@+id/top_pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            app:upv_scrollmode="horizontal"
            app:upv_multiscreen="true"/>
    
        <com.tmall.ultraviewpager.UltraViewPager android:id="@+id/bottom_pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            app:upv_scrollmode="horizontal"
            app:upv_multiscreen="true"/>
    
    </LinearLayout>
    

    This happens when i try to inflate this layout. Also, Error is shown in android studio layout preview. Using library version 1.0.6

    opened by agcom 5
  • please fix, NPE @getCurrentItem

    please fix, NPE @getCurrentItem

    I guess you've already finished NPE in method 'getCurrentItem' in UltraViewPagerView. but you didn't update for users. plz update library ver for us!!!

    Thanx :)

    opened by jhlee910609 4
  • [bug] 首页的pagerAdapter内容改变并没有更新banner里的内容

    [bug] 首页的pagerAdapter内容改变并没有更新banner里的内容

    '''java RequestServerTask: java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 800, found: 2000 Pager id: 2 Pager class: class com.tmall.ultraviewpager.UltraViewPagerView Problematic adapter: class com.tmall.ultraviewpager.UltraViewPagerAdapter at android.support.v4.view.ViewPager.populate(ViewPager.java:1134) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:666) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:628) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:620) at com.tmall.ultraviewpager.UltraViewPagerView.setCurrentItem(UltraViewPagerView.java:215) at com.tmall.ultraviewpager.UltraViewPagerView.setCurrentItem(UltraViewPagerView.java:207) at com.tmall.ultraviewpager.UltraViewPager.setCurrentItem(UltraViewPager.java:419) at com.redteamobile.roaming.fragments.MainLocationFragment.notifyBanner(MainLocationFragment.java:405) at com.redteamobile.roaming.fragments.MainLocationFragment.refreshBanner(MainLocationFragment.java:362) at com.redteamobile.roaming.fragments.MainLocationFragment.onGetBanner(MainLocationFragment.java:430) at com.redteamobile.roaming.fragments.AllLocationsFragment$9.onSuccess(AllLocationsFragment.java:362) at com.redteamobile.roaming.fragments.AllLocationsFragment$9.onSuccess(AllLocationsFragment.java:349) at com.redteamobile.masterbase.remote.RequestServerTask.onPostExecute(RequestServerTask.java:33) at com.redteamobile.masterbase.remote.RequestServerTask.onPostExecute(RequestServerTask.java:10) at android.os.AsyncTask.finish(AsyncTask.java:651) at android.os.AsyncTask.access$500(AsyncTask.java:180) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:179) at android.app.ActivityThread.main(ActivityThread.java:5672) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676) '''

    opened by ostea 4
  • Feature/Update libraries plugins for Android Studio 3.1.2

    Feature/Update libraries plugins for Android Studio 3.1.2

    • Gradle build tool 2.2.2 -> 3.1.2
    • view-inspector-plugin 0.1.1 -> 0.2.0
    • gradle-bintray-plugin 1.4 -> 1.8.0
    • build-info-extractor-gradle 4.0.0 -> 4.7.1
    • android-maven-gradle-plugin 1.5 -> 2.1
    • compileSdk 25 -> 27
    • targetSdk 25 -> 27
    • buildToolVersion 25.0.3 -> 27.0.3
    • gradle 3.3 -> 4.4
    • recyclerview-v7 23.1.1 -> 27.1.1
    • "support-v4" is modularized now and "support-core-ui", "support-compat" included

    No tests run for bintray scripts after plugin upgrades. And also not sure if "api" or "implementation" is better instead of old "compile" for library project

    opened by jemshit 3
  • ScrollView inside UltraViewPager

    ScrollView inside UltraViewPager

    Hi, i am using UltraViewPager with Fragments inside and Fragments have ScrollView. UltraViewPager has scrollMode=VERTICAL. So i want to be able scroll ScrollView inside UltraViewPager, and after scrollView content is scrolled, UltraViewPager should start scrolling to next page. How do you handle such situation, thanks.

    opened by jemshit 3
  • 没法更新数据

    没法更新数据

    使用mUltraVpBanner.getViewPager().getAdapter().notifyDataSetChanged();更新数据只有第一次有作用,后面再调用的话只是item数量发生变化。我是刚开始list只有一条数据,notify()正常;后来又刷新了list,变成了两条数据,再调用notify(),发现只是把刚开始加载的那一个item又复制了一份,展示了两个相同的item

    opened by tianyajuechen 3
  • library not found in mavenCentral, only jcenter

    library not found in mavenCentral, only jcenter

    hello,

    according to this comment, this library is available at mavenCentral

    but when i try to sync using mavenCentral in gradle project level like this:

    buildscript {
        repositories {
            google()
            mavenCentral()
            // jcenter()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:4.1.2"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            // jcenter()
        }
    }
    

    it gives error not found like this

    Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Could not find com.alibaba.android:ultraviewpager:1.0.7.7.
         Searched in the following locations:
           - https://dl.google.com/dl/android/maven2/com/alibaba/android/ultraviewpager/1.0.7.7/ultraviewpager-1.0.7.7.pom
           - https://repo.maven.apache.org/maven2/com/alibaba/android/ultraviewpager/1.0.7.7/ultraviewpager-1.0.7.7.pom
         Required by:
             project :app
    

    any ideas? thanks...

    opened by nashihu 0
  • Bug in switching between different strings.xml

    Bug in switching between different strings.xml

    Can not get a string from the correct strings.xml file. For example, when the app's language is changed, the text view inside the UltraViewPager won't be able to get the string from the new strings.xml file.

    opened by Maryam-T 0
  • 横竖屏切换使用同一个UltraViewpager 子视图滚动方向错乱

    横竖屏切换使用同一个UltraViewpager 子视图滚动方向错乱

    UltraViewpager 的子视图是每页一个recyclerView(长度最大是4个) ,竖屏是一行四列 横向滚动,竖屏是一列四行 纵向滚动。当横竖屏使用同一个的UltraViewPager的时候,首先进入页面之后是竖屏,竖屏正常,切换横屏也正常,但是横屏切换竖屏的后 ,UltraViewPager是横向滑动的,子视图却变成了上下显示,而不是左右显示。

    opened by dingpengqiang 0
  • 此处container未移除子child

    此处container未移除子child

    https://github.com/alibaba/UltraViewPager/blob/c16d1d401d3ba5420281db63c61461143007cd79/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java#L146

    往往在这个重写方法里会去写container.removeView(object),但是此处的object(在instantiateItem创建的RelativeLayout)只是移除他的子view,并未将它从viewpager中移除。(ps:大佬们,这个lib还在继续维护吗?)

    opened by JackyMR 1
Releases(1.0.7.8)
Owner
Alibaba
Alibaba Open Source
Alibaba
Android auto scroll viewpager or viewpager in viewpager

Android Auto Scroll ViewPager ViewPager which can auto scrolling, cycling, decelerating. ViewPager which can be slided normal in parent ViewPager. Att

Trinea 1.7k Dec 10, 2022
An android ViewPager extension allowing infinite scrolling

NO LONGER MAINTAINED LoopingViewPager An android ViewPager extension allowing infinite scrolling. You can use it with "standart" PagerAdapter (inflati

Leszek Mzyk 992 Nov 10, 2022
Combine ViewPager and Animations to provide a simple way to create applications' guide pages.

WoWoViewPager WoWoViewPager combines ViewPager and Animations to provide a simple way to create applications' guide pages. When users are dragging WoW

黄伟平 2.7k Dec 30, 2022
Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. With Kotlin support!

Don't write a ViewPager Adapter! Hook up your ViewPager to your data model using Android Data Binding Framework. Show some ❤️ ?? Sweet and short libra

Rakshak R.Hegde 180 Nov 18, 2022
Persons cards list viewpager - Persons cards list viewpager using kotlin

persons_cards_list_viewpager Дизайн и условие взяты из https://github.com/appKOD

Mironov Ury 1 Mar 1, 2022
PagedGrid - Custom android view composed by multiple page grids with custom content and layout

PagedGrid A PagedGrid is a ViewPager which pages are GridLayout with equal distributed rows and columns. This project is an Android library, written i

Matteo Pellegrino 1 Jan 23, 2019
This project aims to provide a working page flip implementation for usage in ListView.

Changes: Made clickable views like a button clickable inside the FlipViewPager. Use RecyclerView. Updated to API 23. Added support for close clicks on

Yalantis 1.8k Dec 13, 2022
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Ian Thomas 2.5k Dec 31, 2022
Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.

Android ViewPagerIndicator Paging indicator widgets that are compatible with the ViewPager from the Android Support Library to improve discoverability

Jake Wharton 10.2k Jan 3, 2023
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

ogaclejapan 7k Jan 1, 2023
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Florent CHAMPIGNY 8.2k Dec 29, 2022
A different beautiful ViewPager, with quick swipe controls

HollyViewPager Usage Add a HollyViewPager in your layout <com.github.florent37.hollyviewpager.HollyViewPager android:id="@+id/hollyViewPager"

Florent CHAMPIGNY 1.1k Dec 9, 2022
An interactive indicator to navigate between the different pages of a ViewPager

Android PagerSlidingTabStrip (default Material Design) This library is not maintained anymore and there will be no further releases. For most of the c

JPARDOGO 2.2k Jan 4, 2023
Augment Android's ViewPager with wrap-around functionality.

Infinite View Pager Augment Android's ViewPager with wrap-around functionality. Original StackOverflow question: http://stackoverflow.com/questions/75

Antony Tran 692 Dec 14, 2022
ViewPager that slides vertically.

ExpandablePager Layout that contains a ViewPager and can slide vertically between 2 states (expanded and collapsed). #Requirements Android 4.0+ (Ice C

Telenav Inc 716 Sep 15, 2022
[Development stopped in 2014. Unfinished and not stable - not recommended to use.] An easy-to-use ViewPager subclass with parallax background effect for Android apps.

Development stopped in 2014 Not developed since 2014. Unfinished and not stable - not recommended to use. ParallaxViewPager An easy-to-use ViewPager s

Andras Kindler 437 Dec 29, 2022
Android - A ViewPager page indicator that displays the current page number and (optionally) the page count

NumericPageIndicator A ViewPager page indicator that displays the current page number and (optionally) the page count. It can also display buttons to

Manuel Peinado Gallego 253 Nov 16, 2022
Pager (especially for ViewPager) indicator in two styles: circle & fraction.

PagerIndicator Pager (especially for ViewPager) indicator in two styles: circle & fraction. Demo circle fraction Dependency implementation 'me.liangfe

Fei Liang 212 Nov 28, 2022
Android ViewPager template with cool animation.

glazy-viewpager ViewPager template with cool animation. Preview Dependencies compile 'com.android.support:palette-v7:25.2.0' Usage Refer the implement

Kannan Anbarasan 251 Nov 29, 2022