0

I need to program this animation https://i.stack.imgur.com/02FtY.gif into a constraint layout that had an edit text and a recycler view inside like the picture

enter image description here

and I dont have any idea to achive this.

can someone help me with some ideas ?

Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
  • I think you want a CoordinatorLayout, see if this helps: https://stackoverflow.com/questions/34978250/coordinatorlayout-with-recyclerview-and-collapsing-header – Quinn Dec 18 '20 at 20:13

2 Answers2

0

You can use ObjectAnimator to move your bar up and down. Up to hide it in top and down to show it from top.

Example:

float viewHeight = 100f;
float durationInMs = 1000;

private void animTranslateY(boolean show) {
    float translationY = show ? viewHeight : - viewHeight;
    ObjectAnimator animation = ObjectAnimator.ofFloat(view, "translationY", translationY);
    animation.setDuration(durationInMs);
    animation.start();
}

This function should works for you, only pass it true if you are showing the bar, and false if you are hiding it.

0

You can do that with 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>
Zain
  • 37,492
  • 7
  • 60
  • 84