Android 在卷轴上折叠视图(类似AirBnB explore)
事实上,这个问题有两个问题 1) 我想在用户使用类似AirBnB应用程序的动画滚动时展开/折叠视图(当搜索过滤器出现时)。 我假设他们使用的是带有折叠工具栏的CoordinatorLayout,但我无法复制他们的动画。我猜他们正在使用CoordinatorLayout.Behavior来实现这个结果,但我没能很好地使用它。有人能确认他们使用协调器和协调器行为来实现平滑动画吗 2) 此外,我的问题是,我的观点层次不完全相同 我的选项卡位于我要折叠/展开的布局上方。通过使用CoordinatorLayout.Behavior,是否仍然可以使用CoordinatorLayout进行此操作 有关我在用户单击GO按钮或折叠的搜索字段时实现折叠/展开动画的信息,但这不是我的想法 编辑: 我成功地尝试将TabLayout放在正在折叠的工具栏上方,将它和协调器布局放在一个LinearLayout中 我已经创建了一个布局,以实现我想要的行为Android 在卷轴上折叠视图(类似AirBnB explore),android,android-animation,android-coordinatorlayout,Android,Android Animation,Android Coordinatorlayout,事实上,这个问题有两个问题 1) 我想在用户使用类似AirBnB应用程序的动画滚动时展开/折叠视图(当搜索过滤器出现时)。 我假设他们使用的是带有折叠工具栏的CoordinatorLayout,但我无法复制他们的动画。我猜他们正在使用CoordinatorLayout.Behavior来实现这个结果,但我没能很好地使用它。有人能确认他们使用协调器和协调器行为来实现平滑动画吗 2) 此外,我的问题是,我的观点层次不完全相同 我的选项卡位于我要折叠/展开的布局上方。通过使用CoordinatorLa
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed">
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popular" />
<android.support.design.widget.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Favorites" />
</android.support.design.widget.TabLayout>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="RtlHardcoded">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:id="@+id/summarized_search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:background="@drawable/background_blue_light_rounded"
android:orientation="horizontal"
android:padding="12dp"
app:layout_collapseMode="none">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_search" />
<TextView
android:id="@+id/summarized_search_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="@+id/extended_search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginTop="6dp"
android:orientation="vertical"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:background="@drawable/background_blue_light_rounded"
android:orientation="horizontal"
android:padding="12dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_profile" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:background="@drawable/background_blue_light_rounded"
android:orientation="horizontal"
android:padding="12dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_calendar" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:background="@drawable/background_blue_light_rounded"
android:orientation="horizontal"
android:padding="12dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_poi" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:background="@drawable/background_blue_light_rounded"
android:orientation="horizontal"
android:padding="12dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:src="@drawable/menu_poi" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp" />
</LinearLayout>
<Button
android:id="@+id/validation_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="12dp"
android:layout_marginTop="12dp"
android:text="GO" />
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardElevation="8dp"
app:contentPadding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="8dp"
android:text="@string/lorem"
android:textSize="18sp" />
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
但我不太喜欢我的工具栏将可见性设置为“不可见”,只是为了在折叠工具栏时保留部分视图。可以通过将非折叠字段(搜索视图)放在TableLayout和CoordinatorLayout之间来实现同样的效果。我也取得了同样的成就。因此,无论您试图折叠到0的视图是什么,都应该在CollasingToolBallayout中。如果你需要更多信息,请告诉我 PS:你能成功地复制整个行为吗