Giter Club home page Giter Club logo

materialviewpager's Introduction

MaterialViewPager

Android Arsenal Android Weekly CircleCI

Material Design ViewPager easy to use library

Android app on Google Play

Build screen

Sample

Android app on Google Play

And have a look on a sample Youtube Video : Youtube Link

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:materialviewpager:1.2.3'

//dependencies
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0'

Usage

Add MaterialViewPager to your activity's layout

<com.github.florent37.materialviewpager.MaterialViewPager
    android:id="@+id/materialViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:viewpager_logo="@layout/header_logo"
    app:viewpager_logoMarginTop="100dp"
    app:viewpager_color="@color/colorPrimary"
    app:viewpager_headerHeight="200dp"
    app:viewpager_headerAlpha="1.0"
    app:viewpager_hideLogoWithFade="false"
    app:viewpager_hideToolbarAndTitle="true"
    app:viewpager_enableToolbarElevation="true"
    app:viewpager_parallaxHeaderFactor="1.5"
    app:viewpager_headerAdditionalHeight="20dp"
    app:viewpager_displayToolbarWhenSwipe="true"
    app:viewpager_transparentToolbar="true"
    app:viewpager_animatedHeaderImage="true"
    app:viewpager_disableToolbar="false"

    />

with header_logo.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/logo_white"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/materialviewpager_logoHeight"
    android:text="Material is Good"
    android:textSize="30sp"
    android:textColor="@android:color/white"/>

You will see on Android Studio Preview :

alt preview

To get a beautiful screen and enable preview, you theme may follow

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
</style>

<style name="AppTheme" parent="AppBaseTheme">

   <item name="android:textColorPrimary">@android:color/white</item>
   <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
   <item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>

   <item name="android:windowContentOverlay">@null</item>
   <item name="windowActionBar">false</item>
   <item name="windowNoTitle">true</item>

   <!-- Toolbar Theme / Apply white arrow -->
   <item name="colorControlNormal">@android:color/white</item>
   <item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item>

   <!-- Material Theme -->
   <item name="colorPrimary">@color/colorPrimary</item>
   <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
   <item name="colorAccent">@color/accent_color</item>

   <item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
   <item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>

</style>

<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
    <!-- White arrow -->
    <item name="colorControlNormal">@android:color/white</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/drawerArrowColor</item>
</style>

Retrieve the MaterialViewPager

You can use MaterialViewPager as an usual Android View, and get it by findViewById

public class MainActivity extends ActionBarActivity {

    private MaterialViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    }
}

Customisation

First choose your color and height

<com.github.florent37.materialviewpager.MaterialViewPager
        android:id="@+id/materialViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ...
        app:viewpager_color="@color/colorPrimary"
        app:viewpager_headerHeight="200dp"
        ...
        />

Set your logo

<com.github.florent37.materialviewpager.MaterialViewPager
        ...
        app:viewpager_logo="@layout/header_logo" <-- look custom logo layout
        app:viewpager_logoMarginTop="100dp" <-- look at the preview
        ...
        />

Titlebar Logo

Video

Your logo's layout must

  • layout_height="@dimen/materialviewpager_logoHeight"

header_logo.xml

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/logo_white"
    android:layout_width="200dp"
    android:layout_height="@dimen/materialviewpager_logoHeight"
    android:fitsSystemWindows="true"
    android:adjustViewBounds="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/logo_white" />
<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_hideLogoWithFade="false"
        ...
        />

Fading Logo

Video

header_logo.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_centerHorizontal="true"
    android:background="@drawable/circle">

    <ImageView
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:fitsSystemWindows="true"
        android:adjustViewBounds="true"
        android:layout_gravity="center"
        android:src="@drawable/flying" />
</FrameLayout>
<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_hideLogoWithFade="true"
        ...
        />

Toolbar Animation

Hide Logo and Toolbar

Video

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_hideToolbarAndTitle="true"
        ...
        />

Sticky Toolbar

Video

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_hideToolbarAndTitle="false"
        ...
        />

Transparent Toolbar

Video

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_transparentToolbar="true"
        ...
        />

Header Layout

You can replace the header

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_header="@layout/myHeader"
        ...
        />

Moving Header

Or use the default header, with a KenBurns animation

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_animatedHeaderImage="true"
        ...
        />

Static Header

Or simply use an ImageView as header

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_animatedHeaderImage="false"
        ...
        />

Custom Tab Bar

You can set you own tab bar, by default I provided 2 implementations

Standard

Video

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_standard"
        ...
        />

News Stand

Video

<com.github.florent37.materialviewpager.MaterialViewPager`
        ...
        app:viewpager_pagerTitleStrip="@layout/material_view_pager_pagertitlestrip_newstand"
        ...
        />

Or create your own tab bar

Create your own layout using a PagerSlidingTabStrip

my_tabs.xml

<com.astuetz.PagerSlidingTabStrip
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@id/materialviewpager_pagerTitleStrip"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:pstsPaddingMiddle="true"
    app:pstsDividerPadding="20dp"
    app:pstsIndicatorColor="#FFF"
    app:pstsIndicatorHeight="2dp"
    app:pstsShouldExpand="true"
    app:pstsTabPaddingLeftRight="10dp"
    app:pstsTabTextAllCaps="true"
    tools:background="#A333"
     />

Don't forget to give it id="@id/materialviewpager_pagerTitleStrip"

<com.github.florent37.materialviewpager.MaterialViewPager
        ...
        app:viewpager_pagerTitleStrip="@layout/my_tabs"
        ...
        />

Animate Header

Video

Simply add a listen to the ViewPager

mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
            @Override
            public HeaderDesign getHeaderDesign(int page) {
                switch (page) {
                    case 0:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.blue,
                                "http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2014/06/wallpaper_51.jpg");
                    case 1:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.green,
                                "https://fs01.androidpit.info/a/63/0e/android-l-wallpapers-630ea6-h900.jpg");
                    case 2:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.cyan,
                                "http://www.droid-life.com/wp-content/uploads/2014/10/lollipop-wallpapers10.jpg");
                    case 3:
                        return HeaderDesign.fromColorResAndUrl(
                                R.color.red,
                                "http://www.tothemobile.com/wp-content/uploads/2014/07/original.jpg");
                }

                //execute others actions if needed (ex : modify your header logo)

                return null;
            }
        });

Available

HeaderDesign.fromColorAndUrl(Color.BLUE,"http:...);
HeaderDesign.fromColorResAndUrl(R.color.blue,"http:...);
HeaderDesign.fromColorAndDrawable(Color.BLUE,myDrawable);
HeaderDesign.fromColorResAndDrawable(R.color.blue,myDrawable);

Toolbar

Toolbar toolbar = mViewPager.getToolbar();

if (toolbar != null) {
     setSupportActionBar(toolbar);

     ActionBar actionBar = getSupportActionBar();
     actionBar.setDisplayHomeAsUpEnabled(true);
     actionBar.setDisplayShowHomeEnabled(true);
     actionBar.setDisplayShowTitleEnabled(true);
     actionBar.setDisplayUseLogoEnabled(false);
     actionBar.setHomeButtonEnabled(true);
}

ViewPager

ViewPager viewPager = mViewPager.getViewPager();
viewPage.setAdapter(...);

//After set an adapter to the ViewPager
mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());

RecyclerView

mRecyclerView.addItemDecoration(new MaterialViewPagerHeaderDecorator());
mRecyclerView.setAdapter(yourAdapter);

ScrollView

The ScrollView must be an NestedScrollView`

MaterialViewPagerHelper.registerScrollView(getActivity(), mScrollView, null);

And include @layout/material_view_pager_placeholder` as first child

<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <include layout="@layout/material_view_pager_placeholder"/>

        ...your content...

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

CHANGELOG

1.2.0

  • header decorator instead of Adapter

1.1.3

  • header is now clickable
  • fixed some scrolling issues

1.1.2

  • quick scroll fix
  • can set a custom viewpager with app:viewpager_viewpager (the viewpager id must be id/materialviewpager_viewpager)

1.1.0

  • orientation change fix
  • header image display fix
  • elements on header are now clickable
  • notifyHeaderChanged

1.0.8

  • added attribute viewpager_disableToolbar

1.0.7

  • fix bug on low resolutions

1.0.6

  • added attribute transparentToolbar
  • added attribute animatedHeaderImage
  • fixed bug when page is too small to scroll
  • modified HeaderDesign implementation

1.0.5

  • smoother toolbar scrolling
  • fixed bug with fitSystemWindow
  • added HeaderDesign to modify the header color & image
  • added displayToolbarWhenSwipe attribute

1.0.4

Fixed :

  • Orientation changed
  • Memory Leak
  • Android >2.3 with NineOldAndroid
  • Removed ListView usage

1.0.3

Fixed : Rapid scrolling results in varying Toolbar height

RecyclerViewMaterialAdapter can handle a custom placeholder cells count (usefull for GridLayoutManager)

public RecyclerViewMaterialAdapter(RecyclerView.Adapter adapter, int placeholderSize)

1.0.2

Added attributes

app:viewpager_parallaxHeaderFactor="1.5"
app:viewpager_headerAdditionalHeight="20dp"

parallaxHeaderFactor Modify the speed of parallax header scroll (not the speed of KenBurns effect) parallaxHeaderFactor Set up the height of the header's layout displayed behind the first cards view

Fixed issue when scroll down & scroll up multiples time while hideToolbarAndTitle="true"

1.0.1

Added attributes

viewpager_headerAlpha="0.6"

Community

Looking for contributors, feel free to fork !

Tell me if you're using my library in your application, I'll share it in this README

Dependencies

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 florent37, Inc.

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.

materialviewpager's People

Contributors

adamaviner avatar ashok-varma avatar bloderxd avatar bryant1410 avatar championswimmer avatar dan-silver avatar emansih avatar ericwjr avatar florent37 avatar gitter-badger avatar idragon81 avatar jesster2k10 avatar rameshvarun avatar tapashee avatar tigerhix avatar vjubert avatar zorroblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialviewpager's Issues

MaterialViewPager Background color

Hi,

First of all thanks for making this library. :)

I got a problem after you updated to 1.0.3.3 version setColor doesn't work properly anymore.

_pager.setColor(Color.parseColor(_model.color), 0);

I think the problem is related with MaterialViewPagerAnimator.java

Could you please check it ?

Strange bahaviour with RecyclerView

Hello everybody,
I'm implementing MaterialViewPager with several fragments. One of them is a simple RecyclerView. This is my fragment XML

<?xml version="1.0" encoding="utf-8"?>
<com.github.ksoichiro.android.observablescrollview.ObservableScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <include layout="@layout/material_view_pager_placeholder" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/details_list"
        android:layout_width="match_parent"
        android:layout_height="300dp">

    </android.support.v7.widget.RecyclerView>

</LinearLayout>
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>

and this is my main activity xml:

<com.github.florent37.materialviewpager.MaterialViewPager
android:id="@+id/materialViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:viewpager_pagerTitleStrip="@layout/my_tabs"
app:viewpager_logoMarginTop="100dp"
app:viewpager_headerHeight="200dp"
app:viewpager_headerAlpha="1"
app:viewpager_color="@color/hc_blu_toolbar"
app:viewpager_hideLogoWithFade="true"
app:viewpager_hideToolbarAndTitle="false"
android:textColor="@android:color/white"
app:viewpager_enableToolbarElevation="true"
app:viewpager_parallaxHeaderFactor="1.5"
app:viewpager_headerAdditionalHeight="0dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" />

Now, what happens is that while custom layouts (for other fragments) without listViews or recyclerVires get loaded smoothly, with header picture and all, this RecyclerView of mine behaves strangely: it seems like there's a huge padding above the recyclerView itself and a smaller one above it. Also, picture is not loaded in the header.

This is a sort of screencast I made in order to let you know what I'm talking about.

screencast_viewpager

I think all is fine in my code, of course. Recyclerview's content are the ones I expect and everything works, except for this bad, bad behaviour when scrolling and the too-large-top-and-bottom-paddings.

I have no clue about how to get out of this. Do you have any idea?

Thank you

RecyclerView dataset change, the Placeholder should not show all

Hi,florent,
I have RecyclerView in one pager
and the viewpager behaves sticky toolbar
I scroll the recyclerview to some position but not the start, so the placeholder is hide,
then I change the dataset and call the adapter notifyDataSetChanged().

the PlaceHolder in recycerview shows all its size,not part.

It should hide itself, and let the item under it adjust to the pagerstriptab.

thanks!

Bring all resources under MVP namespace

The base theme in the library is AppTheme which collides with the AppTheme of the main app. Please bring these resources under MaterialViewPager namespace, for eg: MVP_AppTheme.

items overlaps header and tabs on orientation change

I am using the latest code still this issues is being faced by me. When I rotate the device after scrolling few list items if I now rotate the device the issue happens see the image for more details
screenshot_2015-05-13-16-39-36

The above screenshot is taken after I rotate the device from landscape to portrait mode.

Any fix for this issue

Issue with webview

Look the white background at the top of webview.. It is covering the backgorund set to viewpager.. Is this a bug?

screenshot_2015-05-27-12-32-26 1

Error: AppCompat does not support the current theme features

Just tried your library and sample code and it's giving me the following error:

AppCompat does not support the current theme features

I'm using targetSdkVersion 22 so had to change ActionBarActivity to AppCompatActivity.

Here is the full log report:

05-06 04:43:27.346: E/AndroidRuntime(24499): FATAL EXCEPTION: main
05-06 04:43:27.346: E/AndroidRuntime(24499): Process: com.github.florent37.materialviewpager.sample, PID: 24499
05-06 04:43:27.346: E/AndroidRuntime(24499): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.florent37.materialviewpager.sample/com.github.florent37.materialviewpager.sample.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread.access$800(ActivityThread.java:144)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.os.Looper.loop(Looper.java:135)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread.main(ActivityThread.java:5221)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at java.lang.reflect.Method.invoke(Native Method)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at java.lang.reflect.Method.invoke(Method.java:372)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
05-06 04:43:27.346: E/AndroidRuntime(24499): Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at com.github.florent37.materialviewpager.sample.MainActivity.onCreate(MainActivity.java:34)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.Activity.performCreate(Activity.java:5933)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
05-06 04:43:27.346: E/AndroidRuntime(24499):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
05-06 04:43:27.346: E/AndroidRuntime(24499):    ... 10 more

Toolbar and tabs doesn't appear when you swipe the ViewPager

If the header are hidden in the current ViewPager item when you scroll it doesn't appear again.
I have manage to make it work somehow

  • In the MaterialViewPagerAnimator I added two methods:

*registerViewPager allows to me to track the ViewPager's page change events

public void registerViewPager(PagerSlidingTabStrip viewPager) {
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {
                onPagerStateChanged();
            }
        });
    }

*onPagerStateChanged allows to me check the header state through lastYOffset parameter

public void onPagerStateChanged() {
if (ENABLE_LOG)
            Log.d(TAG, "scrollDown");

        if (lastYOffset > mHeader.toolbarLayout.getHeight()) {

            animateEnterToolbarLayout(lastYOffset);


        } else if (lastYOffset <= mHeader.toolbarLayout.getHeight()) {
            if (headerAnimator != null) {
                ViewHelper.setTranslationY(mHeader.toolbarLayout, 0);
                followScrollToolbarIsVisible = true;
            } else {
                headerYOffset = Float.MAX_VALUE;
                followScrollToolbarLayout(lastYOffset);
            }
        }
}
  • In MaterialViewPagerHelper I added method to register the ViewPager to the animator:
 /**
     * Register a PagerSlidingTabStrip to the current MaterialViewPagerAnimator
     *
     * @param activity         current context
     * @param pagerSlidingTabStrip     the scrollable
     */
    public static void registerViewPager(Activity activity, PagerSlidingTabStrip pagerSlidingTabStrip) {
        if (activity != null && hashMap.containsKey(activity)) {
            MaterialViewPagerAnimator animator = hashMap.get(activity);
            if (animator != null) {
                animator.registerViewPager(pagerSlidingTabStrip);
            }
        }
    }
  • Finally register the ViewPager in your activity:
        MaterialViewPagerHelper.registerViewPager(this, mViewPager.getPagerTitleStrip());

Anything Holding it back from Lower API

Hi, I find this really nice, but was just wondering what special things are holding it back from working on a lower api, maybe 11.

If they aren't that critical, I'm interested in working on making it work on a lower api.

Please allow setImageFromFile()

I have image files stored locally and I wish I could set them on MaterialViewPager using some setImageFromFile() instead setImageUrl().

Could be nice if the method take screen width and logo height into account resizing the bitmap in case picture File was very large :)

Header animation dosent'work

Hi, I added a MaterialViewPager in one Fragment, and for the first time, all worked well, Header scrolled together with RecylerView.But so wierd that for the second time,RecyclerView scrolled without Header anymore。

Gif

Fragment incorrect attached

Fragment incorrect attached. All code i took from sample, but i don't now, where this bug can be.

Screenshot:
screenshot_2015-05-31-23-30-25 1

Sorry, for my english

Header View stay hidden when i remove last item of RecyclerView

Hello,
I use MaterialViewPager with RecyclerView, everything is ok, but when i try to remove an item from my recycler adapter (generally the last), i cant see the header view anymore. When i scroll to top after item removed, the header view stays collapsed and i dont know why.

Can you help me ?

parallax problem

parallax is not working right when using a lower dpi device (mdpi)
g

How disable header and show only tabs with elevation?

Hello,

Please, tell me: how disable header (picture) and show only tabs with elevation?
I want give this:
2015-05-21 19-26-32

I try set:
viewpager_headerHeight="120dp"
viewpager_headerAlpha="0"
viewpager_parallaxHeaderFactor="0"
viewpager_hideToolbarAndTitle="false"

And have this (bug?):
animation1432226533

What am i doing wrong?
(device: nexus5 (5.1.1))

Flickering of fragments when using ObservableScrollView or ObservableListView

This is an issue in Android-ObservableScrollView. See: ksoichiro/Android-ObservableScrollView#117

To fix it you could add the following code in registerScrollView and registerListView in MaterialViewPagerAnimator.

public void registerScrollView(final ObservableScrollView scrollView,
        final ObservableScrollViewCallbacks observableScrollViewCallbacks) {
    if (scrollView != null) {
        scrollViewList.add(scrollView); // add to the scrollable list
        // fix flickering
        scrollView.setTouchInterceptionViewGroup((ViewGroup) scrollView.getParent().getParent());
        ...
public void registerListView(final ObservableListView listView,
        final ObservableScrollViewCallbacks observableScrollViewCallbacks) {
    if (listView != null) {
        scrollViewList.add(listView); // add to the scrollable list
        listView.setTouchInterceptionViewGroup((ViewGroup) listView.getParent().getParent());
        ...

This will use the RelativeLayout in material_view_pager_layout.xml as the ViewGroup. Inspired by this workaround: ksoichiro/Android-ObservableScrollView@f17e3ce

maybe a bug?

after(sorry,I made a clerical error 'before') I set the mViewPager.setImageDrawable(bg_img,fadeDuration); when I scroll in this page,throws a java.lang.StackOverflowError
at com.github.florent37.materialviewpager.MaterialViewPagerAnimator.onMaterialScrolled(MaterialViewPagerAnimator.java:194)
I deleted this code:
dispatchScrollOffset(source, minMax(0, yOffset, scrollMaxDp));

It woks,so it's a Bug?

The last tab item string not shown completely

I am using most of the code from the sample except for my own tabs -
This is how it's shown
screenshot_2015-05-11-13-34-45 1

The tab should show the complete tab name "Borrowed"
I also tried -

mViewPager.getPagerTitleStrip().setShouldExpand(true);

didn't work.

how to make drawerlayout behide toolbar?

I found that
if I want make drawerlayout behide toolbar,
i must change the layout for MaterialViewPager.

could you please add a custom option for making drawerlayout behide toolbar?

thank you

another fragment shows full screen

not able to use a fragment that contains listview. if i add the listview it looks in whole screen. the effect that is on another fragments not getting in listview.

Any way to remove tab indicator?

I'm using this library with dynamic content. Sometimes the dynamic content means I only have one list (one fragment in pager adapter).

When there's only one fragment, the tab indicators don't make sense, so I'd like to hide them.

When I try to hide the tabs, it looks fine until this happens (on scroll back up):

mvpproblem

Maybe can you add option app:viewpager_pagerTitleStrip="none" and programmatic option as well for when there's only one list? I know observableScrollView library supports this so it should be fairly possible. Maybe some math is hard-coded for animations though, which might make this a bit more than setting a certain layout visibility to just gone.

Can't load a picture. Something wrong in URL?

Hello,
I'm implementing MaterialViewPager and I'd like to have this picture as header background: https://photo1.hotelsclick.com/venice/21186/grandi/best-western-albergo-san-marco-facciata.73.jpg

I noticed it doesn't work, the picture can't be loaded. But I don't get any error in the logs and I don't know what's wrong with it. I'm pretty sure the issue is in the URL or in the way the picture gets loaded, because if I download the picture and load it into another server on another url (say http://www.marcozanetti.it/blog/wp-content/uploads/2015/05/best-western-albergo-san-marco-facciata.73.jpg) it works perfectly.

Do you happen to know what could be this due to? Is this maybe a Picasso issue? I tried to clone MaterialViewPager library in order to add it as library source project and debug picture loading but couldn't make it to add the library to the project :-/

Please let me know if I can provide further data in order to find a proper solution, for me and for others who could be experiencing the same issue.

Transparent color over the header image

Hi!

Please apologize my bad English.

Is there a way to have a full transparent color over the header image? When I use #00000000 as viewpager_color, there is a white overlay over the header image. I want to see the header image without overlay.

Thank you very much for this super library!

pull-up loads

Hello, I want to use in this project the drop-down refresh, pull-up loads more can be achieved, can you help me

Dark halo for Image background

Could you please provide a way to display an halo over the background image ?
Some images I'm using are bright, and my header and tabs are not always visible.

Header cant scroll down when switching Tab and Recyclerview has not enough elements to scroll

Hello,

the Problem is that the ObservableScrollView/Recyclerview in one Fragment remains in its position if there is not enough content in the Recyclerview to scroll, while another Recyclerview is scrolled in another Fragment. Therefore the Header cant be scrolled down again when switching Fragments. This leads to the next Problem: there is a big gap between header and content.

Some bugs in theme, header and list (video)

When I implement your library to my project, I found some bugs and since I use maven link, I think it should be fixed from the library itself.

Here is a video in which I reproduced them: https://youtu.be/m9G9UN0p5ng

  • 1: (0:0 - 0:17) Strange behaviour of theme: when the app is loaded the first time, the toolbar is placed behind the statusbar thus being covered by the statusbar (notice the position of toolbar's buttons). But when rotate the screen, the toolbar is placed below the statusbar. It should be place below the statusbar at the first time. Not sure if it's because of my project or the library.
  • 2: (0:17 - 0:36) When I scroll up in a page, then swipe to next few pages, then I scroll down again so the header can be shown fully, I swipe back to previous page, then I can see the strange position of the list.

screenshot_2015-05-26-15-07-05

  • 3: (0:36 - 0:50) Again when I scroll up, there's a chance that in some pages the list will not be scroll thus leaving a white space above the list.

screenshot_2015-05-26-15-25-04

I can send you the source of my project if you want.

Tab text color is black

How do i change the tab text color? Because currently the tab text color is black and i cannot really see it.

Gradle unable to resolve dependency for Materialviewpager library

I've been unable to compile Materialviewpager as a gradle dependency. I've included it exactly as specified in the documentation. I've been able to compile other third-party libraries via gradle with no problem. Please see the screenshot of the exact error below. Thanks for your help!
dependencies { compile ('com.github.florent37:materialviewpager:1.0.3.3@aar'){ transitive = true } }

screen shot 2015-05-19 at 3 44 30 pm

Fragment webview is not working properly

java.lang.NoSuchMethodError: android.webkit.WebView.evaluateJavascript at com.github.florent37.materialviewpager.MaterialViewPagerHelper.injectHeader(MaterialViewPagerHelper.java:141)
at com.example.materialviewpager..fragments.WebViewFragment$1.onPageFinished(WebViewFragment.java:45)

in line number 45 this code is written
MaterialViewPagerHelper.injectHeader(mWebView, true);

[Question] NullPointerException in AS Preview

Hey,
I am new to your Material ViewPager and not sure if it is an issue or not. When copying your code (from README, "Usage") into my layout, this error appears in the Android Studio Design Tab:

java.lang.NullPointerException at com.github.florent37.materialviewpager.MaterialViewPager.onFinishInflate(MaterialViewPager.java:70) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:814) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:385) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590) at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:351) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

My Code in Android Studio:
`

<com.github.florent37.materialviewpager.MaterialViewPager
    android:id="@+id/materialViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:viewpager_logo="@layout/header_logo"
    app:viewpager_logoMarginTop="100dp"
    app:viewpager_color="@color/colorPrimary"
    app:viewpager_headerHeight="200dp"
    app:viewpager_headerAlpha="1.0"
    app:viewpager_hideLogoWithFade="true"
    app:viewpager_hideToolbarAndTitle="true"
    app:viewpager_enableToolbarElevation="true"
    />
`

What can I do?

Regards,
DDerTyp

Add custom font for application using Calligraphy

I am getting this issue when trying to apply custom font for my application. I am using Calligraphy.

I have mentioned the below lines in my theme, still getting this error. I tried without the Calligraphy, it is working fine. Problem when i added Calligraphy only.
name="windowActionBar" false
name="windowNoTitle" true

06-03 09:16:47.812 2100-2100/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.github.florent37.materialviewpager.sample, PID: 2100
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.florent37.materialviewpager.sample/com.github.florent37.materialviewpager.sample.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.github.florent37.materialviewpager.sample.MainActivity.onCreate(MainActivity.java:52)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            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)

Up button lacks animation

When I use MaterialViewPager on the Activity that presents UP arrow button, clicking on it executes no ripple animation

Strangely, after screen rotation, the animation is there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.