本文介绍了应该在哪里设置"app:layout_behavior"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该在 AppBarLayout 兄弟姐妹的网站上进行设置父级或同级内部的第一个Scrollable视图?

Should it be set at the AppBarLayout sibling's parent or at the first Scrollable View inside its sibling?

使用 Android的材料设计,就有视图,可让我们根据布局的周围环境来处理布局的行为,其中之一是 CoordinatorLayout ,如此CodePath指南提到:

With Material Design for Android, there are Views that let us work with the behavior of the layout depending on its surroundings, one of them is the CoordinatorLayout, as this CodePath guide mentions:

我现在感兴趣的是:

因此,我们将 AppBarLayout 与设置了app:layout_scrollFlags工具栏和另一个 ViewGroup 到.

So, we would use the AppBarLayout with a Toolbar with app:layout_scrollFlags set and another ViewGroup sibling to the AppBarLayout with app:layout_behavior.

我的问题是:我们应该将哪个确切的ViewGroup(或View)放在哪个位置app:layout_behavior?

My question is: in what exact ViewGroup (or maybe View) should we put thatapp:layout_behavior?

到目前为止,我已经尝试过了(他们都已经完成了工作,而且他们都是AppBarLayout的同级兄弟):

So far, I've tried with (And they have all worked, and they are all siblings to the AppBarLayout):

  • 滚动视图

  • Scrolling View

可滚动视图中的第一个ViewGroup

First ViewGroup inside a Scrollable View

ViewGroup内部的ScrollView

ScrollView inside a ViewGroup

而这个没有用:

  • 没有可滚动查看子级的ViewGroup.

在线上有多个示例,但是没有一个真正说明您应该在哪里放置它,例如:

There are multiple examples online, but none of them really state where should you put it, like:

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/与android-design-support-library配合使用

推荐答案

检查此链接: https://developer.android.com/reference/android/support/design/widget/AppBarLayout.html

他们提到过,应该是View,它将显示在AppBarLayout下,如下所示:

They mentioned about that, it should be the View which will be shown under the AppBarLayout 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.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>


在此链接中: http://guides.codepath.com/android /Handling-Scrolls-with-CoordinatorLayout

这篇关于应该在哪里设置"app:layout_behavior"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 18:50