1、 AppBarLayout.OnOffsetChangedListener:
在你下拉刷新时候, 即 appBar下拉到0后即: verticalOffset == 0 时候,开始对指定页面刷新;否则不刷新。
public void onOffsetChanged (AppBarLayout appBarLayout, int verticalOffset) {
if (storeFragment == null || mZoneFragment == null)
return;
if (verticalOffset == 0) {
storeFragment.setCanRefresh (true);
mZoneFragment.setCanRefresh (true);
} else {
storeFragment.setCanRefresh (false);
mZoneFragment.setCanRefresh (false);
}
实现viewPage在滑动时候,AppBar自动隐藏,这里用到CoordinatorLayout能做什么?看http://blog.csdn.net/huachao1001/article/details/51554608
2、<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:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blue"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetStart="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<android.support.design.widget.TabLayout
android:id="@+id/tb_risk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:tabGravity="fill"
app:tabIndicatorColor="@color/blue"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/blue"
app:tabTextColor="@color/light_gray"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/vp_risk"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
网友评论