turing-tech / materialscrollbar Goto Github PK
View Code? Open in Web Editor NEWAn Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
License: Apache License 2.0
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
License: Apache License 2.0
The latest version of Google Now Launcher has new kind of Scroller, it isn't completely different just a bit smart.
Can you try to make MaterialScrollBar
like that way?
setHandleColour int or String version does try to set the indicator color even if there's no indicator configured.
This leads to a NPE crash
((GradientDrawable)indicator.getBackground()).setColor(handleColour); shoud test indicator for null.
I have a transparent toolbar and the RecyclerView
is underneath it (as the scrollbar is as well). To correctly show the scrollbar, the scrollbar gets a margin on top. This works fine. The problem now is, I would like the popup indicator to never be above the top position of the scrollbar.
Example:
The scrollbar is positioned in a container view and has a padding of 50dp. So I want the popup to consider the top of the scrollbar + 50dp as the top of the region that is available for the popup, resulting in a popup that is never drawn partly above this border...
I am using "DragScrollBar" via XML Method and its working fine. But I am having this one issue that, its not showing character indicator for the last item in RecyclerView. It only shows indicator for the item that comes in top of the screen while scrolling. Is there any way to fix it ?
Google Now Launcher
https://dl2.pushbulletusercontent.com/6iCRivv5PNNpvCuK9JfZdqYkITXQOI5T/Screenshot_20160625-153425.png
In Google Now Launcher, it shows indicator for the last item also
@krimin-killr21 The library is too damn exciting, I'm eager to put it in my app. The current ScrollBar
style but I can it be improved?
Just the background, the popup is perfect
There's setHandleColour()
but I see no XML attribute counterpart for that feature. Can it be added please?
Hi,
You just bumped major version number from 9 to 10. But there's CHANGELOG so we know what changed?
Additionally, README does not reflect attributes' prefix addition.
Hi, I used this easy to use library with another library which is SuperRecyclerView
https://github.com/Malinskiy/SuperRecyclerView
And the scroll bar doesn't show up, I try all the possible ways to solve it but couldn't
I have been using this library since a while and I have found this issue which is extremely minor but really effective issue. I found this issue when I was scrolling through list where the bubble obstructed the view and was difficult to read the alphabet in the bubble.
Here's the solution which I think:
Increasing the size of bubble
Increasing the space between bubble and the handle
Increase the space when setting addSpace
to true
addIndicator({{Indicator}}, {{addSpace}});
Unfortunately cannot pin down the steps to recreate but very occasionally I get a null pointer exception. Any ideas?
Crash:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference
at android.support.v7.widget.RecyclerView$LayoutManager.getDecoratedTop(RecyclerView.java:7675)
at com.turingtechnologies.materialscrollbar.ScrollingUtilities.getCurScrollState(ScrollingUtilities.java:152)
at com.turingtechnologies.materialscrollbar.ScrollingUtilities.scrollToPositionAtProgress(ScrollingUtilities.java:107)
at com.turingtechnologies.materialscrollbar.MaterialScrollBar.onDown(MaterialScrollBar.java:634)
at com.turingtechnologies.materialscrollbar.DragScrollBar$1.onTouch(DragScrollBar.java:74)
at android.view.View.dispatchTouchEvent(View.java:9296)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2547)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
at android.app.Activity.dispatchTouchEvent(Activity.java:2771)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
at android.view.View.dispatchPointerEvent(View.java:9520)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:36
java.lang.NullPointerException: Attempt to read from field 'float android.graphics.RectF.left' on a null object reference
at android.graphics.Canvas.drawArc(Canvas.java:1197)
at com.turingtechnologies.materialscrollbar.Handle.onDraw(Handle.java:90)
at android.view.View.draw(View.java:16184)
at android.view.View.updateDisplayListIfDirty(View.java:15180)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16187)
at android.view.View.updateDisplayListIfDirty(View.java:15180)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1077)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
...
Hey @krimin-killr21
The AppBarLayout
is used to perform scrolling techniques one of which is Showing and Hiding Toolbar
on scroll which affects the ScrollBar
.
I'll try to provide screenshot of this issue for better understanding. You can look this issue to understand the problem pluscubed/recycler-fast-scroll#4
No matter what I do, I simply can't get the MaterialScrollBar to show.
I've tried using the XML way of inserting the scrollbar and the programmatic way.
Here is my XML
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/activity_background">
<me.ccrama.redditslide.Views.GeneralSwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/vertical_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="vertical" />
<com.turingtechnologies.materialscrollbar.TouchScrollBar
android:id="@+id/dragScrollBar"
app:recyclerView="@id/vertical_content"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:lightOnTouch="true"
app:barThickness="4"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</me.ccrama.redditslide.Views.GeneralSwipeRefreshLayout>
</FrameLayout>
And here is how I would create it in the class:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
v = localInflater.inflate(R.layout.fragment_verticalcontenttoolbar, container, false);
rv = ((RecyclerView) v.findViewById(R.id.vertical_content));
TouchScrollBar msb = new TouchScrollBar(getActivity(), rv, true);
rv.setLayoutManager(mLayoutManager);
rv.getLayoutManager().scrollToPosition(0);
doAdapter(); //sets the adapter on rv
return v;
}
No matter what--nothing shows. What am I doing wrong?
I discovered following two problems in a list:
RecyclerView
itself and then retouch the bar, it shows the LAST KNOWN indicator...Probably related to the points above is, that the public Character getCharacterForElement(int element)
sometimes is called with indexes that are out of bounds...
Hi,
I got a NullPointerException:
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(llm);
mMaterialScrollBar = new DragScrollBar(getActivity(), mRecyclerView, true);
mMaterialScrollBar.setHandleColourRes(R.color.main_green);
java.lang.NullPointerException: Attempt to read from field 'float android.graphics.RectF.left' on a null object reference
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.graphics.Canvas.drawArc(Canvas.java:1197)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at com.turingtechnologies.materialscrollbar.Handle.onDraw(Handle.java:81)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:16184)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15180)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:16187)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15180)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1077)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:16187)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15180)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1229)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15175)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:15954)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.draw(View.java:16187)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15180)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
01-26 17:42:37.950 17845-17845/com.swapcard.apps.android E/AndroidRuntime: at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
Hi @krimin-killr21
Excellent library. There are couple of situations like Empty list, etc when the scroller is not needed can there be any method for this. I guess I tested setVisibility()
which didn't work out.
My compileSdkVersion has to be 22 or less, due to 3rd party constraints.
This creates the error:
Error:Failed to resolve: com.android.support:appcompat-v7:24.0.0
Install Repository and sync project
Is there any way around this, an earlier release of your library perhaps?
This is my code:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
View view = inflater.inflate(R.layout.music_list_fragment_layout, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
materialScrollBar = new MaterialScrollBar(getActivity(), recyclerView, true);
materialScrollBar.setHandleColour(R.color.accentColor);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
musicRecyclerAdapter = new MusicRecyclerAdapter(getActivity(), pSongs);
musicRecyclerAdapter.setMusicFragmentListener(this);
recyclerView.setAdapter(musicRecyclerAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setItemAnimator(new DefaultItemAnimator());
return view;
}
And here is the recyclerView's xml code:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="8dp"
android:scrollbars="vertical" />
English is not my native language so I think I lost myself here:
"Also note that the library does not currently support recyclerViews which do not boarder the screen's edge on the right side." - from what I understood it means that I should apply a padding or margin to the right side of the recyclerview, but I tried that and it's not working. Can someone explain me what is wrong with my code? A short example of how to apply it properly to the recyclerview would be great, thanks!
I have created a RecyclerView adapter implementing INameableAdapter for DragScrollBar. It works flawlessly during first creation of fragment in ViewPager. However when I swipe 2 fragments to the left/right, the fragment is destroyed, therefore it will be automatically recreated. This message pops out during those recreation progress: com.turingtechnologies.materialscrollbar.CustomExceptions$AdapterNotSetupForIndicatorException: In order to add this indicator, the adapter for your recyclerView MUST implement INameableAdapter.
Currently I have to stop fragment recreation with mViewPager.setOffscreenPageLimit(...)
to avoid crashing.
Hi,
Great update, it workd almost perfectly!!
Just one thing I noticed:
Before the update i was able to use method setHandeColour(int), passing the color itself as parameter.
Now It doesn't work anymore because of the following new line of code in your method, that throws resourceNotFound.. etc...
handleColour = getResources().getColor(colour);
Is there a chance to get back also the old implementation?
In my app, for example, I saved the real accentColor integer (choosed by user) in sharedpreferences and it would be very uncomfortable retrieving the resourceId.
Thanks in advance
We should be able to directly click on the scrollbar, I mean at any position apart from handle and on clicking that position the ListView
or RecyclerView` should jump to that position.
It's the default behavior of a FastScroll
in Android and I think it's missing in this library.
PS: The library is getting too awesome.
How can I specify the TouchScrollBar width?
Some attributes like i.e. barThickness
are not accepting dimentions ("dp") values, just raw values. This is bad and unnecesary, and can be easily corrected by fixing faulty definition of the attributes. Instead of
<attr name="barThickness" format="integer"/>
it should rather be
<attr name="barThickness" format="dimension"/>
or even better
<attr name="barThickness" format="dimension|reference"/>
The same for majority of other attributes. All of then should be extended by adding |reference
. As this is small change I do not bother doing PR, but imho attr.xml
should be looking like this:
<resources>
<declare-styleable name="MaterialScrollBar">
<attr name="recyclerView" format="reference"/>
<attr name="lightOnTouch" format="boolean|reference"/>
<attr name="handleColour" format="color|reference"/>
<attr name="barColour" format="color|reference"/>
<attr name="handleOffColour" format="color|reference"/>
<attr name="textColour" format="color|reference"/>
<attr name="barThickness" format="dimension|reference"/>
</declare-styleable>
<declare-styleable name="TouchScrollBar">
<attr name="hideDelayInMilliseconds" format="integer|reference"/>
<attr name="autoHide" format="boolean|reference"/>
</declare-styleable>
</resources>
I wrap my items in a Wrapper class which ads header items to the underlying data. Headers will have a span size equal to the columns in the GridLayoutManager
and headers have one. Setup looks like following:
((GridLayoutManager) rvContent2.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (rvContent2 == null) // may happen while activity is destroyed!
return 1;
return adapter.isHeader(position) ? ((GridLayoutManager) rvContent2.getLayoutManager()).getSpanCount() : 1;
}
});
Seems like scrolling logic does not work with such a setup due to different item sizes and spans?
Hello,
I've got a RecyclerView with multiple ViewHolders that all have a separate layout file with a different height (for example 20dp, 40dp and 60dp). So each row has a different (but static) height. When i use the TouchScrollBar it doesn't scroll smoothly trough the items. Is there a way to support this?
Hi @krimin-killr21
Currently we can directly use MaterialScrollBar
directly from Java. But it takes the flexibility, so can you create a some view like com.packagename.MaterialScrollBar
which would be really cool & flexible to move in layout hierarchy.
Let me know what you think about it.
Hi, This library is getting extremely better.
I feel instead of getting int
using INameableAdapter
you can make it generic that means we will get T
in the method.
Moreover I get -1
causing ArrayIndexOutOfBoundException
.
This is not an important issue but will make the library more better, I'll try to have a pull request for generics
Hi,
I updated MaterialScrollBar to the lastest and I noticed that it doesn't work properly on Android 2.3.7.
When scrolling, the recyclerview scrolls and the letter inside the bubble changes, but both the scroller and the bubble stuck on the top and don't move.
Version 7.0.0 worked fine.
Regards.
Marcello
Hi,
I randomly got a force close in my application.
In my fragment:
recyclerView.setAdapter(adapter);
TouchScrollBar touchScrollBar = (TouchScrollBar) view.findViewById(R.id.touch_scroll_bar);
touchScrollBar.addIndicator(new CustomIndicator(getContext()), true);
(without xml is identically)
An idea ?
When I use a Drawer on the right in combination with the scrollbar on the right, the scrollbar will catch the touch of opening the drawer and interprete it as a touch on the sidebar... Which results in a scroll the the corresponding position in the list...
Any ideas how to solve that?
Hi,
I got this issue only when the RecyclerView is empty:
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/reveal_notification">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="@color/search_bar"/>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Hi,
MaterialScrollBar Is completely useless in the scenario where you have few RecyclerViews in the layout (i.e. tab layout), all using the same android:id
. This is perfectly valid scenario, however using the same Id for more than object can cause some troubles. And you just stepped on that :)
For example let's have 2 RVs, both are using android:id="@+id/recycler"
. 1st is just recycler with plain adapter, no fancy stuff. But we want MaterialScrollBar to be used with 2nd one, so it uses different adapter and implements i.e. ICustomScroller
etc. All is fine. Then you set up the layout, plant MaterialScrollBar. But then you to have add recycler reference:
app:msb_recyclerView="@id/recycler"
And now we have 50% of chance for crash due to uncaught CustomExceptions$AdapterNotSetupForIndicatorException
.
The problem lies in this line:
But things can go even worse, if adapters of both recyclers are implementing expected interface - in such case, scroller will be scrolling wrong recycler and showing hints from wrong dataset.
To fix this issue msb_recyclerView
must not be mandatory at instantiation time, but at run time + you must be able to set the same from code (i.e. via setRecyclerView()
) which will allow to wire scrollbar with proper recycler.
If the user jumps from an index that has a text with lower width (like in alphabet the letter "i") to an index that has a longer text (like "m") then the letter is cut on display. This only happens when the user directly jumps to the position by pressing the scroll bar on a place where the indicator would display the longer text.
Step 2 (jumping directly to letter "M"):
This was reproduced on an Android 4.1.1 device, ATM I don't know if it applies to other Android versions or not.
Please let me know if you need any further details. Thank you for you for this library.
Testing this library and get into a small problem.
I'm using setAutoHide(true) to have the bar auto hiding.
The bug is easy to trigger scroll the list to have the bar showing.
Start dragging the scroller up and down for a more or less long time after a few seconds the scroll bar auto hide while still dragging and scrolling.
It will auto shows again after 1/2 second and will work correctly after that.
Hello, I was evaluating to use this library, but it doesn't display in the Bubble the latest value of RecyclerView when scrolling.
It stops at the first value when fully scrolled down.
It would be great having the possibility to create labels with more than 1 char.
For example, in a index sorted by page, it could be useful to have the number of the page in the label.
I think that as long as getCharacterForElement() return a Character, this is not possibile.
Could you give a look if it's possible to add this feature?
Thanks in advance.
Marcello
It seems currently when fastscrolling the library does not trigger the RecyclerView OnScrollListener listeners.
This is problematic when some other things depends on this being called.
It would be nice to include support for that.
Thanks.
Hi, if you try to use MaterialScrollBar with Kotlin and try to call method
addIndicator(indicator, false) or other DragScrollBar methods you got an error:
java.lang.IllegalAccessError: Illegal class access: 'com.example.app.BaseListFragment' attempting to access 'com.turingtechnologies.materialscrollbar.Indicator'
First of all, this is a great library and thank you for making it.
I have a use case where the items in my RecyclerView
feature a button on the right side to show a popupMenu. I already adjusted the thickness of the TouchScrollBar
using setBarThickness
so that it fits into the margin between the button's right edge and the screen's edge, but it still seems to intercept touches on my buttons. This lead me to the conclusion, that reducing the thickness only reduces the visible size of the TouchScrollBar
but not the thickness of the zone where it actually intercepts TouchEvent
s.
Correct me if I'm wrong and if not: is there a way to reduce that thickness likewise?
Thanks in advance, cheers!
Have someone successfully perform filtering with this library? I have tried to put Filterable implemented in my RecyclerView adapter. However, there is a constant crash when getFilter().filter()
is triggered: java.lang.ArrayIndexOutOfBoundsException
is called on getCharacterForElement()
.
MaterialScrollBar's attribute names should be prefixed to avoid disambiguation and potential conflict with other libraries. Unfortunately Android is not well designed in that area and app:
namespace is always getting all attributes from app or additional libraries.
so instead of barThickness
it should be i.e. msb_barThickness
, instead of lightOnTouch
it should be msb_lightOnTouch
etc.
Hi, I have a recyclerview where sometimes I need to show a scrollbar, other times I don't.
The elements on the recyclerview changes at run time, so I would decide when scroolbar should go away and when it should show.
The problem is that I'm not able to do that. I've tried with the method scrollBar.setScrollBarHidden(false) with a scrollbar added through code, and using scrollBar.setVisibility(GONE) with a scrollbar added trough XML.
When my recyclerview in swiperefreshlayout scroll doesn't show. What can i do for solve ?
Hi,
I found a couple of bugs on the indicator:
On API < 21, the indicator color doesn't change, neither setting handle colour (tested on API 17 and 19).
See image below:
On API <= 10, the indicator is reverse and it doesn't hide after stop scrolling.
See image below:
This is my code:
new MaterialScrollBar(getActivity(), recyclerView, true) .addIndicator(new AlphabetIndicator(getActivity())) .setHideDuration(Utility.HIDE_DELAY) .setHandleColour(String.format("#%06X", 0xFFFFFF & getThemeUtils().accentColor())) .setAutoHide(true);
HIDE_DELAY = 1500
Me again :)
Seems currently the lib does not support GridLayoutManager.
Is there plan to support those ?
Would you accept PR if not ?
A last one for today:)
setHandleColour(int) can lead to unfortunate collision if seeking for a color value that clash with a color resource id.
This is very rare but can happens.
Maybe handle this like other libs :
setHandleColour(int color)
setHandleColourRes(int colorResid) / setColorResId ?
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.