florent37 / materialviewpager Goto Github PK
View Code? Open in Web Editor NEWA Material Design ViewPager easy to use library
Home Page: https://www.fiches-plateau-moto.fr
License: Apache License 2.0
A Material Design ViewPager easy to use library
Home Page: https://www.fiches-plateau-moto.fr
License: Apache License 2.0
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.
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.
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
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);
}
}
}
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);
}
}
}
MaterialViewPagerHelper.registerViewPager(this, mViewPager.getPagerTitleStrip());
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
The above screenshot is taken after I rotate the device from landscape to portrait mode.
Any fix for this issue
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.
Hello, I want to use in this project the drop-down refresh, pull-up loads more can be achieved, can you help me
When I build source with compileSdkVersion 22 , throw a exception : Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features.
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.
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.
I started using https://github.com/square/leakcanary to find potential memory leaks in my application.
Turns out there is one in your great library in MaterialViewPagerHelper. Indeed, it holds a static HashMap
that is never cleared. Maybe you could add a method to clear the content of that map when the Activity
/Fragment
is destroyed?
Please support StaggeredGridLayoutManager as it implements scrollToPositionWithOffset() too but did not extends LinearLayoutManager.
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!
Been getting I/ViewUtils﹕ app:theme is now deprecated. Please move to using android:theme instead.
in the logs. Please update the toolbar declaration in XML file material_view_pager_layout.xml
.
Hi!
I need to change tabs titles color from ViewPager xml file or Java object without change color in styles.
How i can do this?
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 ?
mViewPager.getViewPager().setCurrentItem(1)
is not working properly. It is displaying only the card view, without the header and the tabs.
Is there any other way to achieve this?
please support android 2.3 too
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):
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.
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
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 } }
Hi, Would you explain how can we add icon on every tab we creates?
@florent37 Wanted to make a gridView inside of ObservableScrollVeiw i set up as your directions. but the griditems coming like another pages cardsview. i wants a simple GridView. not popping towards the tabs. will send you snapshot soon. plus can we set status bar's color a bit likely the color for this fragment that you set in main activity.
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!
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.
I need to remove toolbar somehow... I think its impossible at this moment , but toolbar could be optional in future libs releases
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.
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
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 :)
I have this line MaterialViewPagerHelper.registerRecyclerView(getActivity(), betsRecycler, null); on OnCreateView of Fragment
MaterialViewPager layout from sample/ Recycler :
<android.support.v7.widget.RecyclerView
android:id="@+id/bets_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"/>
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
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.
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
there is a bug when a recyclerview has more than 1 spanCount
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
Make it out of box.
Just add a callback to return the ImageView.
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);
How do i change the tab text color? Because currently the tab text color is black and i cannot really see it.
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
I can send you the source of my project if you want.
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 ?
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 scrolling animation is very laggy.
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.