android - Collapsing toolbar, tabLayout and ViewPager not working properly after scroll -


enter image description here

i trying create similar layout user profile screen in app. here need: 1. back, plus , image button should in toolbar in collapsed expanded state. 2. toolbar should transparent in expanded state , change color of content scrim on being collapsed. 3. served(180) , cooked(300) text should clickable , lead other activities. 4. on collapsing, tablayout should pinned below toolbar. 5. viewpager attached tabs should work fine , contains listview.

here attempt:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#231f20"     android:fitssystemwindows="true">      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margintop="?attr/actionbarsize"         app:layout_behavior="@string/appbar_scrolling_view_behavior" />      <android.support.design.widget.tablayout         android:id="@+id/tabs"         android:layout_width="match_parent"         android:layout_height="?attr/actionbarsize"         android:layout_gravity="bottom"         android:background="#231f20"         app:layout_anchor="@+id/appbar"         app:layout_anchorgravity="bottom"         app:tabgravity="fill"         app:tabmode="fixed" />      <android.support.design.widget.appbarlayout         android:id="@+id/appbar"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:fitssystemwindows="true"         android:theme="@style/themeoverlay.appcompat.dark.actionbar">          <android.support.design.widget.collapsingtoolbarlayout             android:id="@+id/collapsing_toolbar"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:fitssystemwindows="true"             app:contentscrim="#fac80a"             app:layout_scrollflags="scroll|exituntilcollapsed"             app:expandedtitlemarginstart="200dp"             app:expandedtitlemarginbottom="110dp">               <relativelayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:fitssystemwindows="true"                 app:layout_collapsemode="parallax">                  // contains background image, profile pic,textview etc.              </relativelayout>              <android.support.v7.widget.toolbar                 android:id="@+id/toolbar"                 android:layout_width="match_parent"                 android:layout_height="?attr/actionbarsize"                 app:layout_collapsemode="pin"                 app:popuptheme="@style/themeoverlay.appcompat.light">              </android.support.v7.widget.toolbar>          </android.support.design.widget.collapsingtoolbarlayout>      </android.support.design.widget.appbarlayout>   </android.support.design.widget.coordinatorlayout> 

problem : clicking anywhere on collapsing toolbar's contents(inside relative layout) in beginning not cause problem scrolling(collapsing toolbar, scrolling viewpager contents, changing tabs) , again come collapsing toolbar in expanded state, , click anywhere on it, app crashes. getting following error:

09-21 07:28:38.740    5462-5462/com.galleri5.android e/inputeventreceiver﹕ exception dispatching input event. 09-21 07:28:38.741    5462-5462/com.galleri5.android e/messagequeue-jni﹕ exception in messagequeue callback: handlereceivecallback 09-21 07:28:38.744    5462-5462/com.galleri5.android e/messagequeue-jni﹕ java.lang.nullpointerexception: attempt invoke virtual method 'float android.view.motionevent.getx()' on null object reference             @ android.view.view.ontouchevent(view.java:9321)             @ android.support.design.widget.coordinatorlayout.ontouchevent(coordinatorlayout.java:449)             @ android.view.view.dispatchtouchevent(view.java:8388)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2424)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2158)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:2569)             @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1743)             @ android.app.activity.dispatchtouchevent(activity.java:2739)             @ android.support.v7.internal.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)             @ android.support.v7.internal.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)             @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2530)             @ android.view.view.dispatchpointerevent(view.java:8578)             @ android.view.viewrootimpl$viewpostimeinputstage.processpointerevent(viewrootimpl.java:4028)             @ android.view.viewrootimpl$viewpostimeinputstage.onprocess(viewrootimpl.java:3894)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3509)             @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3475)             @ android.view.viewrootimpl$asyncinputstage.forward(viewrootimpl.java:3585)             @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3483)             @ android.view.viewrootimpl$asyncinputstage.apply(viewrootimpl.java:3642)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3509)             @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3475)             @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3483)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:5708)             @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:5682)             @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:5653)             @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:5798)             @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:185)             @ android.os.messagequeue.nativepollonce(native method)             @ android.os.messagequeue.next(messagequeue.java:143)             @ android.os.looper.loop(looper.java:122)             @ android.app.activitythread.main(activitythread.java:5254)             @ java.lang.reflect.method.invoke(native method)             @ java.lang.reflect.method.invoke(method.java:372)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:898)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:693) 09-21 07:28:38.747    5462-5462/com.galleri5.android e/androidruntime﹕ fatal exception: main     process: com.galleri5.android, pid: 5462     java.lang.nullpointerexception: attempt invoke virtual method 'float android.view.motionevent.getx()' on null object reference             @ android.view.view.ontouchevent(view.java:9321)             @ android.support.design.widget.coordinatorlayout.ontouchevent(coordinatorlayout.java:449)             @ android.view.view.dispatchtouchevent(view.java:8388)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2424)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2158)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2430)             @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2119)             @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:2569)             @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1743)             @ android.app.activity.dispatchtouchevent(activity.java:2739)             @ android.support.v7.internal.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)             @ android.support.v7.internal.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)             @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2530)             @ android.view.view.dispatchpointerevent(view.java:8578)             @ android.view.viewrootimpl$viewpostimeinputstage.processpointerevent(viewrootimpl.java:4028)             @ android.view.viewrootimpl$viewpostimeinputstage.onprocess(viewrootimpl.java:3894)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3509)             @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3475)             @ android.view.viewrootimpl$asyncinputstage.forward(viewrootimpl.java:3585)             @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3483)             @ android.view.viewrootimpl$asyncinputstage.apply(viewrootimpl.java:3642)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3509)             @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3475)             @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3483)             @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3456)             @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:5708)             @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:5682)             @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:5653)             @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:5798)             @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:185)             @ android.os.messagequeue.nativepollonce(native method)             @ android.os.messagequeue.next(messagequeue.java:143)             @ android.os.looper.loop(looper.java:122)             @ android.app.activitythread.main(activitythread.java:5254)             @ java.lang.reflect.method.invoke(native method)             @ java.lang.reflect.method.invoke(method.java:372)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:898)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:693) 

what reason of behavior , how rectify this.

this issue of android support library.

see link details coordinatorlayout nullpointerexception in ontouchevent

according above link issue has been fixed in android support library version-23.0.1

update android support library solve error.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -