【发布时间】:2016-08-25 14:42:15
【问题描述】:
我有一个简单的布局,它是一个CoordinatorLayout,在AppBarLayout 和一个RecyclerView 中包含一个Toolbar。为了在将内容加载到 RecyclerView 时允许进度条,我将它包装在 FrameLayout 旁边,并与 ProgressBar 一起包含在另一个文件中。内容加载时,ProgressBar 设置为VISIBLE,完成后设置为GONE,显示RecyclerView。我想使用ScrollingViewBehavior,这样当我滚动我的RecyclerView 时,Toolbar 就被隐藏了。我尝试将其添加到 FrameLayout 和 RecyclerView 中,但似乎都不起作用。
我必须做什么才能获得我正在寻找的行为?我需要创建一个新的ViewGroup 或类似的东西来显示/隐藏ProgressBar 并为此定义一个新的Behavior,还是有更简单的方法?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ToolbarTheme"
android:background="?attr/colorPrimary"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:id="@+id/recycler_view" />
<include layout="@layout/progress_circle" />
</FrameLayout>
<include layout="@layout/floating_action_button"/>
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
标签: android android-layout android-recyclerview android-framelayout