Tag: android appbarlayout

滚动不适用于CoordinatorLayout +视差图像+ BottomSheetLayout

介绍 我有一个活动,使用CoordinatorLayout , AppBarLayout和CollapsingToolbarLayout实现一个常见的模式与视差标题图像和滚动内容。 我的xml布局看起来像这样: <android.support.design.widget.CoordinatorLayout android:fitsSystemWindows="true" android:layout_height="match_parent" android:layout_width="match_parent"> <android.support.design.widget.AppBarLayout android:fitsSystemWindows="true" android:id="@+id/appbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.design.widget.CollapsingToolbarLayout android:fitsSystemWindows="true" android:layout_height="wrap_content" android:layout_width="match_parent" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <TextView android:background="@color/colorAccent" android:gravity="center" android:layout_height="250dp" android:layout_width="match_parent" android:text="ParallaxImage" app:layout_collapseMode="parallax"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="?attr/actionBarSize" android:layout_width="match_parent" app:layout_collapseMode="pin" app:popupTheme="@style/AppTheme.PopupOverlay"/> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:id="@+id/content" android:layout_height="match_parent" android:layout_width="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <TextView android:layout_height="wrap_content" android:layout_margin="@dimen/text_margin" android:layout_width="wrap_content" android:text="@string/large_text"/> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout> 正如你可以看到在下面的GIF动画,一切工作正常。 您可以从内容NestedScrollView以及Toolbar或视差View滚动整个屏幕。 问题 Google推出了一个BottomSheetBehavior类(Android设计支持库23.2 )来帮助开发者实现Bottom表 。 底部工作表的我的XML布局看起来像这样: […]

仅在AppBarLayout完全展开时启用SwipeRefreshLayout

只有当AppBarLayout完全展开时,我怎样才能启用SwipeRefreshLayout 。 我只需要在下一个滑动手势上启用刷新模式。 现在,我尝试了 appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, final int verticalOffset) { refreshLayout.setEnabled(verticalOffset == 0); } }); 当然,它的作品! 但是它并不像我需要的那样。 此代码在用户继续滑动手势的同时立即启用刷新模式。 我只需要在AppBarLayout扩展后的下一次滑动时启用它。 谁知道如何做到这一点?