物料设计layout_scrollFlags的含义 [英] Material design layout_scrollFlags meanings
问题描述
我发现我们可以使用很酷的标志,通过使用layout_scrollFlags
滚动工具栏和内容.就我而言,我的布局是这样的:
I find out that we can use cool flags that scroll both toolbar and even content by using layout_scrollFlags
. In my case, I have a layout like this:
<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>
我的一个标签页是fragment
,其布局的Recycle View
中的edittext
在RecycleView下面.首先,我想知道该标志的含义
one of my tabs is a fragment
and its layout has a Recycle View
with a edittext
below the RecycleView. firstly I wanna know what this flag means
google说:
- SCROLL_FLAG_ENTER_ALWAYS
进入(在屏幕上滚动)时,无论滚动视图是否也在滚动,该视图都会在任何向下滚动事件上滚动. - SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED
"enterAlways"的附加标志将返回的视图修改为仅最初滚动回到其折叠高度. - SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
退出时(滚动到屏幕之外),视图将一直滚动,直到被折叠"为止. - SCROLL_FLAG_SCROLL
该视图将与滚动事件直接相关地滚动. - SCROLL_FLAG_SNAP
滚动结束后,如果视图仅部分可见,则它将被捕捉并滚动到最接近的边缘.
- SCROLL_FLAG_ENTER_ALWAYS
When entering (scrolling on screen) the view will scroll on any downwards scroll event, regardless of whether the scrolling view is also scrolling. - SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED
An additional flag for 'enterAlways' which modifies the returning view to only initially scroll back to it's collapsed height. - SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
When exiting (scrolling off screen) the view will be scrolled until it is 'collapsed'. - SCROLL_FLAG_SCROLL
The view will be scroll in direct relation to scroll events. - SCROLL_FLAG_SNAP
Upon a scroll ending, if the view is only partially visible then it will be snapped and scrolled to it's closest edge.
我随机更改了此标志,在某些情况下,我的编辑文本消失了,直到我向上滚动工具栏,然后出现编辑.我阅读了Google文档 但我做得不好.我想简单地理解它.
I changed this flag randomly and in some cases my edit text went away till I scrolled the toolbar up and then edit appeared. I read google documents but I could not get it well. I want to understand it in simple terms.
推荐答案
我不知道我的答案是否仍然有用.实际上,文档足以理解周围发生的事情,您只需要进行一些操作即可.
必须启用在属性app:layout_scrollFlags
中使用的scroll
标志,滚动效果才能生效.此标志必须与enterAlways
,enterAlwaysCollapsed
,exitUntilCollapsed
或snap
一起启用:
I don't know if my answer will still be relevant, but nevertheless. Actually docs are quite enough to understand things going around, you just need to play a little bit around.
The scroll
flag used within the attribute app:layout_scrollFlags
must be enabled for any scroll effects to take into effect. This flag must be enabled along with enterAlways
, enterAlwaysCollapsed
, exitUntilCollapsed
, or snap
:
-
enterAlways
:向上滚动视图时,该视图将变为可见.在从列表底部滚动并希望在向上滚动时立即显示工具栏的情况下,此标志很有用. -
enterAlwaysCollapsed
:通常,仅使用enterAlways时,工具栏将继续向下滚动.假定声明了enterAlways并指定了minHeight,则还可以指定enterAlwaysCollapsed.使用此设置时,您的视图将仅以该最小高度显示.仅当滚动到达顶部时,视图才会扩展到其完整高度 -
exitUntilCollapsed
:设置滚动标记后,向下滚动通常会导致整个内容移动.通过指定minHeight和exitUntilCollapsed,将在其余内容开始滚动之前达到工具栏的最小高度并退出屏幕 -
snap
:使用此选项将确定仅部分缩小视图时的处理方式.如果滚动结束并且视图尺寸已减小到其原始尺寸的50%以下,则此视图将返回其原始尺寸.如果大小大于其大小的50%,它将完全消失.
enterAlways
: The view will become visible when scrolling up. This flag is useful in cases when scrolling from the bottom of a list and wanting to expose the Toolbar as soon as scrolling up takes place.enterAlwaysCollapsed
: Normally, when only enterAlways is used, the Toolbar will continue to expand as you scroll down.Assuming enterAlways is declared and you have specified a minHeight, you can also specify enterAlwaysCollapsed. When this setting is used, your view will only appear at this minimum height. Only when scrolling reaches to the top will the view expand to its full heightexitUntilCollapsed
: When the scroll flag is set, scrolling down will normally cause the entire content to move.By specifying a minHeight and exitUntilCollapsed, the minimum height of the Toolbar will be reached before the rest of the content begins to scroll and exit from the screensnap
: Using this option will determine what to do when a view only has been partially reduced. If scrolling ends and the view size has been reduced to less than 50% of its original, then this view to return to its original size. If the size is greater than 50% of its sized, it will disappear completely.
请查看此博客,它的确应该是有帮助的.
Please have a look at this blog it should be really helpful.
更新:此外,还有关于滚动条的另一条文章标志.非常感谢小马丁·奥布拉村!
Update: Also there is another article about scroll flags. Big thanks to Martin Ombura Jr!
这篇关于物料设计layout_scrollFlags的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!