android - onClick method not working properly after NestedScrollView scrolled -
i used nestedscrollview coordinatorlayout enable scroll animation toolbar (by app:layout_scrollflags="scroll|enteralways").
nestedscrollview contain linearlayout root child, put 2 textviews linearlayout enable expand/collapse animation. 1 set visible , other 1 set gone. , switching visibility onclick event of linearlayout
normally, work expected when scrolled nestedscrollview onclick event not working properly. need double click after scroll expand/collapse animation
does have same problem me ? please me
<android.support.design.widget.coordinatorlayout 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.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="98dp" android:paddingleft="24dp" android:paddingright="24dp"> <android.support.v7.widget.appcompattextview android:id="@+id/detail_expense_reason_trim" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleline="false" android:textcolor="@color/add_new_expense_text_color" /> <android.support.v7.widget.appcompattextview android:id="@+id/detail_expense_reason" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleline="false" android:textcolor="@color/add_new_expense_text_color" android:visibility="gone" /> </linearlayout> </android.support.v4.widget.nestedscrollview> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.toolbar android:id="@+id/detail_expense_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:layout_scrollflags="scroll|enteralways" app:popuptheme="@style/themeoverlay.appcompat.light" /> </android.support.design.widget.appbarlayout>
@injectview(r.id.detail_expense_reason) appcompattextview originalreason; @injectview(r.id.detail_expense_reason_trim) appcompattextview trimreason; @injectview(r.id.detail_expense_container) linearlayout expensecontainer;
// handle event
public void onclick() { if (originalreason.getvisibility() == view.visible) { originalreason.setvisibility(view.gone); trimreason.setvisibility(view.visible); } else { originalreason.setvisibility(view.visible); trimreason.setvisibility(view.gone); } }
it bug of nestedscrollview, detail of bug can found in here: issue. problem mscroller.isfinished()
in onintercepttouchevent(motionevent ev)
not return true
after fling operation (even if fling stopped). therefore touch event intercepted.
this bug have been reported while, still have not been fixed. have created own version of bug fix problem. implemented own nestedscrollview
, copied code nestedscrollview
, having following amendments:
public class nestedscrollview extends framelayout implements nestedscrollingparent, nestedscrollingchild { ... private void initscrollview() { ... // replace line: // mscroller = new scrollercompat(getcontext(), null); mscroller = scrollercompat.create(getcontext(), null); ... } @override public boolean onintercepttouchevent(motionevent ev) { ... switch (action & motioneventcompat.action_mask) { ... case motionevent.action_down: { ... // replace line: // misbeingdragged = !mscroller.isfinished(); misbeingdragged = false; ... } } } }
and nestedscrollview
should have same behaviour original one.
Comments
Post a Comment