0

この素晴らしいライブラリを使用して、 が押されたRecyclerViewときにCircularReveal アニメーションを作成しますSearchViewが、小さなバグがあります。アニメーションは正常に動作しますが、 を最初に開いて閉じた後でのみですSearchView。開いActivityて押すと、CircularReveal アニメーションなしSearchViewRecyclerView表示され、閉じて再度開くと、すべて正常に動作します。

ここに私のXMLがあります:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".MapsActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar">

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            class="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="ua.nau.edu.NAU_Guide.MapsActivity"
            tools:layout="@layout/fragment_maps" />

    </RelativeLayout>

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <io.codetail.widget.RevealFrameLayout
        android:id="@+id/reveal_recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerview_user_data"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/grey_bg"
            android:visibility="gone" />
    </io.codetail.widget.RevealFrameLayout>
</RelativeLayout>

私のアニメーションの方法:

private void revealShow(final View view) {
            // get the center for the clipping circle
            int cx = (view.getLeft() + view.getRight()) / 2;
            int cy = (view.getTop() + view.getBottom()) / 2;

            // get the final radius for the clipping circle
            int dx = Math.max(cx, view.getWidth() - cx);
            int dy = Math.max(cy, view.getHeight() - cy);
            float finalRadius = (float) Math.hypot(dx, dy);

            SupportAnimator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(300);
            view.setVisibility(View.VISIBLE);
            animator.start();

        }

        private void revealClose(final View view) {
            // get the center for the clipping circle
            int cx = (view.getLeft() + view.getRight()) / 2;
            int cy = (view.getTop() + view.getBottom()) / 2;

            // get the final radius for the clipping circle
            int dx = Math.max(cx, view.getWidth() - cx);
            int dy = Math.max(cy, view.getHeight() - cy);
            float finalRadius = (float) Math.hypot(dx, dy);

            SupportAnimator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(300);
            animator = animator.reverse();
            animator.start();

            view.postDelayed(new Runnable() {
                @Override
                public void run() {
                    view.setVisibility(View.GONE);
                }
            }, 300);

        }

私のSearchView's OnClickListener

searchView.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Show RecyclerView
                revealShow(recyclerView);

                ...
            }
        });

私のSearchView's OnCloseListener

searchView.setOnCloseListener(new SearchView.OnCloseListener() {
            @Override
            public boolean onClose() {
                Log.d(TAG, "OnCloseListener/ onClose() called");

                // Hide keyboard
                if (getCurrentFocus() != null) {
                    methodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
                }

                // Close RecyclerView & SearchView
                searchView.onActionViewCollapsed();
                revealClose(recyclerView);

                return true;
            }
        });
4

0 に答える 0