turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
778 stars 126 forks source link

Shows error when using LinearLayout instead of RelativeLayout #76

Open tommygoh opened 7 years ago

tommygoh commented 7 years ago

Hey. It's a great library but one thing. When i used Linear Layout for item_layout instead of RelativeLayout it crashed. FATAL EXCEPTION: main Process: com.juvosleep, PID: 3387 java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams at com.turingtechnologies.materialscrollbar.CustomIndicator.getTextElement(CustomIndicator.java:38) at com.turingtechnologies.materialscrollbar.CustomIndicator.getTextElement(CustomIndicator.java:26) at com.turingtechnologies.materialscrollbar.Indicator.setText(Indicator.java:129) at com.turingtechnologies.materialscrollbar.ScrollingUtilities.scrollHandleAndIndicator(ScrollingUtilities.java:70) at com.turingtechnologies.materialscrollbar.MaterialScrollBar$scrollListener.onScrolled(MaterialScrollBar.java:711) at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4541) at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3602) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3265) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3767) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1732) at android.widget.LinearLayout.onLayout(LinearLayout.java:1497) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586) at android.widget.LinearLayout.onLayout(LinearLayout.java:1495) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336) at android.widget.FrameLayout.onLayout(FrameLayout.java:273) at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678) at android.view.View.layout(View.java:16630) at android.view.ViewGroup.layout(ViewGroup.java:5437) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:606) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCall

Am i missing something ? or the library can't use the linearlayout ?

turing-tech commented 7 years ago

What do you mean 'item_layout'?

tommygoh commented 7 years ago

@turing-tech sorry. what i mean is like this. when the recyclerview is in LinearLayout, it crashed, but when i use RelativeLayout it worked

turing-tech commented 7 years ago

That shouldn't mess it up. Anyway, this error suggests that the CustomIndicator class does not see itself as extending RelativeLayout, which its parent class does. Have you altered the library's code at all?