Android - remove background from circular disclosure (Lollipop)

I am in the process of converting my application to a new content template and I noticed a slight annoyance. When I use the Reveal Effect , a white background is seen in front of it before it transitions between visible and invisible.

It currently looks like this when it animates

Start

start

Near

middle

Done

finish

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <include layout="@layout/actionbar_visualizer" />

    <LinearLayout
        android:id="@+id/visualizerProductContainer"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_below="@id/visualizerActionBar"
        android:background="@color/black"
        android:gravity="left"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/gridHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/fifty_transparent_black"
            android:gravity="center"
            android:padding="10dp"
            android:text="@string/products"
            android:textColor="@color/white" />

        <GridView
            android:id="@+id/productGrid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:columnWidth="75dp"
            android:numColumns="auto_fit"
            android:paddingTop="10dp"
            android:stretchMode="columnWidth" />
    </LinearLayout>

    ...

</RelativeLayout>

      

Animation

...
mProductContainer = (LinearLayout)findViewById(R.id.visualizerProductContainer);
...

private void showHideProducts() {
    if (mProductContainer.getVisibility() == View.VISIBLE) {
        int cx = (mProductContainer.getLeft() + mProductContainer.getRight()) / 8;
        int cy = (mProductContainer.getTop() + mProductContainer.getBottom()) / 8;

        int initialRadius = mProductContainer.getWidth();

        Animator anim = ViewAnimationUtils.createCircularReveal(mProductContainer, cx, cy, initialRadius, 0);

        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mProductContainer.setVisibility(View.GONE);
            }
        });

        anim.start();
    } else {
        int cx = (mProductContainer.getLeft() + mProductContainer.getRight()) / 8;
        int cy = (mProductContainer.getTop() + mProductContainer.getBottom()) / 8;

        int finalRadius = Math.max(mProductContainer.getWidth(), mProductContainer.getHeight());

        Animator anim = ViewAnimationUtils.createCircularReveal(mProductContainer, cx, cy, 0, finalRadius);

        mProductContainer.setVisibility(View.VISIBLE);
        anim.start();
    }
}

      

Does anyone know a way to remove the background / make it transparent between animations?

+3


source to share


1 answer


ViewAnimationUtils.createCircularReveal

works by clipping the given view during animation. Since your black background is part of your view, it is cropped as well. Instead, your black background should be set in your activity theme (via android:background

) or in the view that encapsulates the view animation (like yours RelativeLayout

).



+4


source







All Articles