它应该设置在AppBarLayout兄弟的父母或其兄弟姐妹内的第一个Scrollable VIEw吗?
在Material Design for Android中,有Views让我们根据周围环境处理布局的行为,其中一个是CoordinatorLayout,正如this CodePath guide所述:
CoordinatorLayout extends the ability to accomplish many of the
Google’s Material Design scrolling effects. Currently, there are
several ways provIDed in this framework that allow it to work without
needing to write your own custom animation code.
我现在感兴趣的是:
Expanding or contracting the Toolbar or header space to make room for the main content.
因此,我们将使用带有应用程序的Toolbar的AppBarLayout:layout_scrollFlags设置,使用app:layout_behavior将另一个ViewGroup兄弟用于AppBarLayout.
我的问题是:在什么样的VIEwGroup(或者VIEw)中我们应该把它放在那里
应用:layout_behavior?
到目前为止,我已经尝试过(而且他们都已经工作了,他们都是AppbarLayout的兄弟姐妹):
>滚动视图
> Scrollable视图中的第一个VIEwGroup
> VIEwGroup内的ScrollVIEw
而这一个没有用:
>没有Scrollable VIEw子集的VIEwGroup.
在线有多个例子,但没有一个真正说明你应该把它放在哪里,比如:
http://www.ingloriousmind.com/blog/quick-look-on-the-coordinatorlayout/
https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
https://developer.android.com/training/basics/firstapp/building-ui.html
https://www.bignerdranch.com/blog/becoming-material-with-android-design-support-library/
解决方法:
检查此链接:https://developer.android.com/reference/android/support/design/widget/AppBarLayout.html
AppbarLayout
also requires a separate scrolling sibling in order to
kNow when to scroll. The binding is done through theAppbarLayout.ScrollingVIEwBehavior
class, meaning that you
should set your scrolling vIEw’s behavior to be an instance ofAppbarLayout.ScrollingVIEwBehavior
. A string resource containing the
full class name is available.
他们提到了这一点,它应该是将在AppbarLayout下显示的VIEw,如下所示:
<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.v4.Widget.nestedScrollVIEw androID:layout_wIDth="match_parent" androID:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"> <!-- Your scrolling content --> </androID.support.v4.Widget.nestedScrollVIEw> <androID.support.design.Widget.AppbarLayout androID:layout_height="wrap_content" androID:layout_wIDth="match_parent"> <androID.support.v7.Widget.Toolbar ... app:layout_scrollFlags="scroll|enteralways"/> <androID.support.design.Widget.TabLayout ... app:layout_scrollFlags="scroll|enteralways"/> </androID.support.design.Widget.AppbarLayout> </androID.support.design.Widget.CoordinatorLayout>
My question is: in what exact
VIEwGroup
(or maybeVIEw
) should we put
thatapp:layout_behavior
?
在此链接:http://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
总结Next, we need to define an association between the
AppbarLayout
and
the VIEw that will be scrolled. Add anapp:layout_behavior
to aRecyclerVIEw
or any other VIEw capable of nested scrolling such asnestedScrollVIEw
. The support library contains a special string
resource@string/appbar_scrolling_vIEw_behavior
that maps toAppbarLayout.ScrollingVIEwBehavior
, which is used to notify theAppbarLayout
when scroll events occur on this particular vIEw. The
behavior must be established on the vIEw that triggers the event.
以上是内存溢出为你收集整理的android – 应该在哪里’app:layout_behavior’设置?全部内容,希望文章能够帮你解决android – 应该在哪里’app:layout_behavior’设置?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)