smooth-app-bar-layout icon indicating copy to clipboard operation
smooth-app-bar-layout copied to clipboard

Initiate vertical viewpager scroll using tabstrip as well

Open nikhilreprime opened this issue 8 years ago • 18 comments

Using appbar layout user can initiate vertical scroll through tabstrip but in smooth-app-bar this might be overridden by some other functionality

can you please help to get that one also working

nikhilreprime avatar Sep 09 '16 04:09 nikhilreprime

Can you post your sample code here using original AppBarLayout?

henrytao-me avatar Sep 09 '16 05:09 henrytao-me

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme"
        app:layout_behavior="com.crewkarma.common.util.FlingBehavior">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">

        <include
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout="@layout/test"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:id="@+id/header_view"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin"
            android:background="#4b727272">
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:layout_marginRight="16dp"
                android:layout_alignParentEnd="true"
                android:layout_gravity="right"
                android:gravity="center_vertical"
                android:id="@+id/connection_status">

                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:src="@drawable/message_new"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/img_message_user"
                        android:visibility="gone"
                        android:paddingEnd="10dp"
                        android:paddingStart="10dp" />

                    <ImageView
                        android:src="@drawable/connect_new"
                        android:id="@+id/img_connect_user"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:visibility="gone"
                        android:paddingEnd="10dp"
                        android:paddingStart="10dp" />

                    <ImageView
                        android:layout_alignParentEnd="true"
                        android:src="@drawable/people_2"
                        android:id="@+id/img_connection_req_sent"
                        android:layout_width="65dp"
                        android:layout_height="65dp"
                        android:visibility="gone"
                        android:paddingStart="10dp"
                        android:paddingEnd="10dp" />

                    <ImageView
                        android:layout_alignParentEnd="true"
                        android:src="@drawable/connected_new"
                        android:id="@+id/img_connected"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:visibility="gone"
                        android:paddingEnd="10dp"
                        android:paddingStart="10dp" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/img_reject"
                        android:src="@drawable/reject_new"
                        android:visibility="gone"
                        android:paddingEnd="10dp"
                        android:paddingStart="10dp" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/img_accept"
                        android:src="@drawable/accept_new"
                        android:visibility="gone"
                        android:paddingStart="10dp"
                        android:paddingEnd="10dp" />

                </LinearLayout>

            </RelativeLayout>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_gravity="right"
                android:gravity="center_vertical">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/btn_share"
                    android:paddingEnd="16dp"
                    android:src="@drawable/ic_share_blue"
                    android:visibility="gone" />
            </LinearLayout>


        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.CollapsingToolbarLayout>

        <com.crewkarma.common.view.SlidingTabLayout
            android:id="@+id/sliding_tabs"
            android:theme="@style/ThemeOverlay.AppCompat.Light"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            app:tabIndicatorColor="@color/white"
            app:tabGravity="fill"
            android:background="@color/white" />

    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

nikhilreprime avatar Sep 09 '16 07:09 nikhilreprime

thanks for quick response you can use tabLayout instead of slidingTabLayout and you can remove app:layout_behavior from AppBarLayout

please tell me is it possible to fix this issue and also the issue with clickable item not being able to scrollable is not yet fixed , do you have any hack for this issue

thank you

nikhilreprime avatar Sep 09 '16 07:09 nikhilreprime

yes i tried that example, in that If you try to initiate SmoothAppBarLayout vertical scroll starting from view inside TabLayout , your scroll well be neglected and absorbed by some other event

nikhilreprime avatar Sep 10 '16 10:09 nikhilreprime

If you can send me a video or an apk to check, it's awesome.

henrytao-me avatar Sep 10 '16 11:09 henrytao-me

I am sharing the drive like please check the videos

video with scrolling issue https://drive.google.com/open?id=0B50q6ZRb0iPaZ2ktTGpLZ3MyY0U

i am referring twitter for getting similar fill of profile page so the expected behavior is something as follows https://drive.google.com/open?id=0B50q6ZRb0iPabVpUVWFudUVIajg

thank you

nikhilreprime avatar Sep 10 '16 11:09 nikhilreprime

I got what you mean. Looking into it now.

henrytao-me avatar Sep 10 '16 11:09 henrytao-me

Hi @henrytao-me , did you get any solution for @nikhilreprime issue.. twitter like scrolling..?

anukools avatar Sep 22 '16 10:09 anukools

Hi @anukools

I don't have any updates until now. Looking forward to Droidcon NYC next week. Chris Banes is going to have some cool stuffs there.

henrytao-me avatar Sep 22 '16 13:09 henrytao-me

hi @henrytao-me , i am really in pinch because of this issue, can you give me some clue to pin point this issue No clickable element in collapsableToolBar initiates scroll action

i tried this solution on tabStrip in tabLayout but it is not complete and not initiating nested scroll

private class OnTouchListenerStrip implements OnTouchListener { int yOld = 0 , yNew = 0; boolean moved = false; @Override public boolean onTouch(View v, MotionEvent arg1) {

        if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
            yOld = (int)arg1.getAxisValue(MotionEvent.AXIS_Y) ;
            Log.d("Touch Action ",String.valueOf(arg1.getAction() + "  scroll Old " + yOld));
            moved = false ;
            return true;
        } else {
            yNew = (int)arg1.getAxisValue(MotionEvent.AXIS_Y) ;
            if(yOld !=yNew)
            {
                moved = true ;
            }

            if (arg1.getAction() == MotionEvent.ACTION_MOVE) {
                int offset = yNew - yOld ;
                Log.d("Touch Action ",String.valueOf(arg1.getAction() + "old "+yOld +" New "+yNew+"  scroll new - old " + offset));
                yOld = yNew ;
                if(onViewScrollListener != null)
                {
                    onViewScrollListener.onViewScrolled(offset);
                }
                return false;
            }else if(arg1.getAction() == MotionEvent.ACTION_UP)
            {
                if(!moved) {
                    for (int i = 0; i < mTabStrip.getChildCount(); i++) {
                        if (v == mTabStrip.getChildAt(i)) {
                            mViewPager.setCurrentItem(i);
                            return false;
                        }
                    }
                }
            }
        }
        Log.d("Touch Action ","Something else");
        return false;
    }
}

and set the listener final OnTouchListener onTabTouchListener = new OnTouchListenerStrip(); tabView.setOnTouchListener(onTabTouchListener); thank you

nikhilreprime avatar Oct 11 '16 07:10 nikhilreprime

implementation of onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev)

in HeaderBehavior is the place where action move action gets canceled

due to onInit() inside BaseBehavior is setting mDragCallbackListener

if (mDragCallbackListener == null) {

  mDragCallbackListener = new DragCallback() {

    @Override
    public boolean canDrag(AppBarLayout appBarLayout) {
      return false;
    }
  };
  setDragCallback(mDragCallbackListener);

}

can you get this working

nikhilreprime avatar Oct 12 '16 13:10 nikhilreprime

Hi @nikhilreprime

I understand your concern. I just back from Hollands. I will spend one day in weekend to investigate this issue. Try my best to come up with a solution.

I will keep you posted. Thanks.

henrytao-me avatar Oct 14 '16 14:10 henrytao-me

Thank you very Much I really appreciate it On Oct 14, 2016 8:17 PM, "Henry Tao" [email protected] wrote:

Hi @nikhilreprime https://github.com/nikhilreprime

I understand your concern. I just back from Hollands. I will spend one day in weekend to investigate this issue. Try my best to come up with a solution.

I will keep you posted. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/henrytao-me/smooth-app-bar-layout/issues/138#issuecomment-253821331, or mute the thread https://github.com/notifications/unsubscribe-auth/ANBvmOqShbFP1vVgUMBFfQmrSvRZAGfbks5qz5YKgaJpZM4J4sye .

nikhilreprime avatar Oct 14 '16 14:10 nikhilreprime

Hi @nikhilreprime

I haven't had solution for this right now. It's tricky. Touching is still messed up. Sorry.

henrytao-me avatar Oct 18 '16 12:10 henrytao-me

Thanks

I will also try to solve this one If you find the fix please let me know On Oct 18, 2016 6:15 PM, "Henry Tao" [email protected] wrote:

Hi @nikhilreprime https://github.com/nikhilreprime

I haven't had solution for this right now. It's tricky. Touching is still messed up. Sorry.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/henrytao-me/smooth-app-bar-layout/issues/138#issuecomment-254495792, or mute the thread https://github.com/notifications/unsubscribe-auth/ANBvmKF8gydOM3WAzNwu1wuNH-mYYARRks5q1L9SgaJpZM4J4sye .

nikhilreprime avatar Oct 18 '16 15:10 nikhilreprime

hi @henrytao-me did you get time to look into this issue

nikhilreprime avatar Jan 02 '17 07:01 nikhilreprime

Hi @nikhilreprime

Time is flying. I haven't had time for this issue yet. I am really sorry.

henrytao-me avatar Jan 02 '17 07:01 henrytao-me