首页 > 解决方案 > 展开和隐藏布局 Android

问题描述

我需要将此动画 https://i.stack.imgur.com/02FtY.gif编程 到一个约束布局中,该布局有一个编辑文本和一个像图片一样的回收器视图

在此处输入图像描述

我没有任何想法来实现这一点。

有人可以帮我一些想法吗?

标签: androidxmlandroid-animationandroid-motionlayout

解决方案


你可以这样做CoordinatorLayout

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways">

            <androidx.appcompat.widget.SearchView
                android:id="@+id/searchview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:iconifiedByDefault="false"
                android:queryHint="@string/query_hint"
                app:iconifiedByDefault="false"
                app:queryHint="@string/query_hint" />

        </com.google.android.material.appbar.CollapsingToolbarLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


</androidx.coordinatorlayout.widget.CoordinatorLayout>

推荐阅读