Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ObjectAnimator and BlurView together then UI frames drop a lot. #9

Closed
imknown opened this issue Mar 1, 2017 · 3 comments
Closed

Comments

@imknown
Copy link

imknown commented Mar 1, 2017

Activity has one BlurView. I show some Views by using ObjectAnimator. Frames drop too many.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/colors">

    <com.github.mmin18.widget.RealtimeBlurView
        android:id="@+id/blurView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        app:realtimeBlurRadius="10dp"
        app:realtimeOverlayColor="#BB000000" />

    <Button
        android:id="@+id/source"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="30dp"
        android:background="@drawable/shape_circle"
        android:text=""
        android:textSize="50sp" />

</RelativeLayout>
private void doExpandAnim() {
    blurView.setVisibility(View.VISIBLE);

    PropertyValuesHolder z1 = PropertyValuesHolder.ofFloat("alpha", 0, 1);
    ObjectAnimator z = ObjectAnimator.ofPropertyValuesHolder(blurView, z1);
    z.setInterpolator(new LinearInterpolator());
    z.setDuration(350);

    PropertyValuesHolder c1 = PropertyValuesHolder.ofFloat("rotation", 0, 360 + 45);
    ObjectAnimator c = ObjectAnimator.ofPropertyValuesHolder(source, c1);
    c.setDuration(350);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(z, c);
    animatorSet.start();
}

private void doCollapseAnim() {
    PropertyValuesHolder z1 = PropertyValuesHolder.ofFloat("alpha", 1, 0);
    ObjectAnimator z = ObjectAnimator.ofPropertyValuesHolder(blurView, z1);
    z.setInterpolator(new LinearInterpolator());
    z.setDuration(350);
    z.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            blurView.setVisibility(View.GONE);
        }
    });

    PropertyValuesHolder c1 = PropertyValuesHolder.ofFloat("rotation", 360 + 45, 0);
    ObjectAnimator c = ObjectAnimator.ofPropertyValuesHolder(source, c1);
    c.setDuration(350);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(z, c);
    animatorSet.start();
}
@imknown
Copy link
Author

imknown commented Mar 1, 2017

But using PopupWindow / Dialog does not have this problem.

@mmin18
Copy link
Owner

mmin18 commented Mar 1, 2017

Can't reproduce. I'm testing on a galaxy s3 phone. Add some buttons under the blur view.
device-2017-03-01-175955

@imknown
Copy link
Author

imknown commented Mar 1, 2017

WOW!! THX A LOT!! You are right!!

I find that i closed the hardware accelerated for this.

I should NOT use at all:

android:hardwareAccelerated="false"

and

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEA
    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}

use these instead:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

ozodrukh/CircularReveal#109 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants