我在SwipeRefreshLayout中使用了android.support.design.widget.TabLayout,并且我注意到如果我的水平滑动有任何轻微的向下变化,则在水平寻呼机滑动之前处理SwipeRefreshLayout。目前,由于这个原因,很难刷取视图寻呼机。
我想修改SwipeRefresh以仅在滑动更垂直时进行响应,以便更轻松地进行水平滑动。或者也许有更好的方法来解决这个问题?
这是我的示例应用的activity_main.xml
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tabLayout"/>
</RelativeLayout>
这是我的MainActivity的onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
mSwipe = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
mSwipe.setOnRefreshListener(this);
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.viewPager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mTabLayout.setupWithViewPager(mViewPager);
}