0

然后viewpager刷卡我有典型的CoordinatorLayout + AppBarLayout +工具栏+ TabLayout + Viewpager在工具栏上有与layout_scrollFlags一个非常恼人的问题“滚动| enterAlways |弹簧”设置RecyclerView滚动第一和CoordinatorLayout

这里是也有其与NavigationView一个DrawerLayout的XML:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_tabs_main_drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/activity_tabs_main_coordinator_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/activity_tabs_main_appbar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <android.support.v7.widget.Toolbar 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/material_toolbar" 
       style="@style/AppCompatTheme.Toolbar" 
       app:layout_scrollFlags="scroll|enterAlways|snap" 
       app:popupTheme="@style/material_toolbar_popup"/> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/activity_tabs_main_tab_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabIndicatorColor="@color/neon_green"/> 
     </android.support.design.widget.AppBarLayout> 

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

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

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:menu="@menu/drawer_item"/> 

</android.support.v4.widget.DrawerLayout> 

,我注意到的是,我可以刷卡在viewpager标签对角线的方式(见图片附后),而在谷歌Play上真正的两个问题应用程序或WhatsApp或Cheesesquare由克里斯·贝恩如果我试图做一个对角线滑动RecyclerView采取吨他首先手势并向下滚动/向上滚动。

ViewPager Toolbar Bounce bugs

我觉得这ViewPager的行为使工具栏创建一个小的反弹,其中导航抽屉图标设置,旁边的Toolbat标题。

所以,真正的问题是试图防止这种反弹问题或错误,你也可以查看该视频

YouTube链接:Video to show the bounce effect in the Toolbar

我已经通过去除DrawerLayout和NavigationView尝试,但没有任何效果,反弹问题仍在继续。

提前致谢!

+0

如果你尝试包内NestedScrollView的'ViewPager'并有' 'NestedScrollView'中的app:layout_behavior'。 – WindRider

+0

因为克里斯贝恩在cheesesquare没有这样做,但我会尝试。如果我将一个FrameLayout中的viewpager包装在一起会怎样? –

+0

+完全没做任何事情的WindRider =( –

回答

0

我想我找到了解决这个问题的办法。 RecyclerView.ViewHolder内部添加View.OnClickListener()后几乎察觉不到,可以吗?

这里是内部RecyclerView:

private RecyclerOnItemClickListener itemClickListener; 

    class PostDtoViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 

     private final PostView postView; 

     public PostDtoViewHolder(PostView postView) { 
      super(postView); 
      this.postView = postView; 
      this.postView.setOnClickListener(this); 
     } 

     public View getViewHolder() { 
      return this.postView; 
     } 

     public void bind(PostDto postDto) { 
      postView.loadContent(postDto); 
     } 

     @Override 
     public void onClick(View v) { 
      itemClickListener.onItemClickListener(getAdapterPosition()); 
     } 
    } 

哪里RecyclerOnItemClickListener只是与方法的接口代码:

public interface RecyclerOnItemClickListener { 

    void onItemClickListener(int itemPosition); 
} 
相关问题