No Circular Animation
burnix opened this issue · 2 comments
burnix commented
I'm trying to simply add animation, following to your guide, but all what can I see is empty screen and flat card view in 1,5 seconds... No Circular animation.
MainActivity:
CardView myView = (CardView) findViewById(R.id.awesome_card);
// get the center for the clipping circle
int cx = (myView.getLeft() + myView.getRight()) / 2;
int cy = (myView.getTop() + myView.getBottom()) / 2;
// get the final radius for the clipping circle
int dx = Math.max(cx, myView.getWidth() - cx);
int dy = Math.max(cy, myView.getHeight() - cy);
float finalRadius = (float) Math.hypot(dx, dy);
SupportAnimator animator =
ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(1500);
animator.start();
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="vertical"
tools:context="com.igor.librarytest.MainActivity">
<io.codetail.widget.RevealFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Put more views here if you want, it's stock frame layout -->
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/awesome_card"
style="@style/CardView"
app:cardBackgroundColor="#AFB42B"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
/>
</io.codetail.widget.RevealFrameLayout>
</LinearLayout>
Gradle:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.nineoldandroids:library:2.4.0+'
compile('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
transitive = true;
}
What did I miss? Thanks in advance.
P.S. min API is 15. Testing on 19.
ozodrukh commented
burnix commented
@ozodrukh thank you!
this was my solution
public void onWindowFocusChanged (boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
AnimationDrawable frameAnimation =
(AnimationDrawable) animation.getBackground();
if(hasFocus) {
frameAnimation.start();
} else {
frameAnimation.stop();
}
}