Ken*_*nji 44 flags android scroll android-layout material-design
我发现我们可以使用酷炫的标志来滚动工具栏甚至内容layout_scrollFlags.就我而言,我有这样的布局:
<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.support.design.widget.AppBarLayout
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="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="snap"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我的标签之一是fragment与它的版面Recycle View与edittext该RecycleView下方.首先,我想知道这面旗帜意味着什么
谷歌说:
我随机更改了这个标志,在某些情况下,我的编辑文本消失,直到我向上滚动工具栏然后编辑出现.我阅读谷歌文档,但我不能很好.我想简单地理解它.
Yur*_*sap 82
我不知道我的答案是否仍然有用,但不过.实际上,文档足以理解周围的事情,你只需要玩一点点.
必须启用
属性中使用的滚动标志app:layout_scrollFlags才能使任何滚动效果生效.此标志必须与一起启用enterAlways,enterAlwaysCollapsed,exitUntilCollapsed,或snap:
enterAlways:向上滚动时视图将变为可见.当从列表底部滚动并希望在向上滚动时显示工具栏时,此标志非常有用.enterAlwaysCollapsed:通常,当仅使用enterAlways时,工具栏将在您向下滚动时继续展开.当您声明enterAlways并指定了minHeight时,您还可以指定enterAlwaysCollapsed.使用此设置时,您的视图将仅显示在此最小高度.仅当滚动到达顶部时,视图才会扩展到其完整高度exitUntilCollapsed:当设置滚动标志时,向下滚动通常会导致整个内容移动.通过指定minHeight和exitUntilCollapsed,将在其余内容开始滚动并退出屏幕之前达到工具栏的最小高度snap:使用此选项将确定仅在部分缩小视图时要执行的操作.如果滚动结束且视图大小已减小到原始视图的小于50%,则此视图将恢复为原始大小.如果尺寸大于其尺寸的50%,它将完全消失.请看一下这个博客应该真的很有帮助.
| 归档时间: |
|
| 查看次数: |
32785 次 |
| 最近记录: |