Как использовать CircularReveal?

1,00
р.
Хочу поставить CircularReveal, не могу разобраться с этой библиотекой. Не получается сделать ее рабочей, хоть и onClick поставил. Ничего не происходит, даже ошибок не выдает. Вот мой код
final View myView = v.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.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation) myView.setVisibility(View.INVISIBLE) } }) animator.start()
XMl - код

<!-- Put more views here if you want, it's stock frame layout -->


добавил в build.gradle следующее:
compile ('com.github.ozodrukh:CircularReveal:1.3.1@aar') { transitive = true }
build.gradle (глобальный)
allprojects { repositories { jcenter() maven { url "https://jitpack.io" } }
Вот сама библиотека - https://github.com/ozodrukh/CircularReveal
Еще сайт, откуда я брал OnClick - http:/tfalcon.com/blog/post/android-material-design

Ответ
Окей, я вырвал код из своего тестового проекта. Думаю, разберетьсь :D Здесь фаб стоит между двумя контейнерами, изначально с картинкой плюсика. При нажатии на фаб он анимацией поворота превращается в крестик и из его центра идет волна на верхний контейнер. При повторном нажатии волна обратно задвигается в центр в фаб и он обратно превращается а плюсик
XML







android:clickable="true" android:src="@drawable/fab_add" app:backgroundTint="#8D1B14" app:layout_anchor="@id/viewA" app:layout_anchorGravity="bottom|center"/>

JAVA
public class FABMorph extends AppCompatActivity { boolean morph = false @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState) setContentView(R.layout.fabmorph) final FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fabm) final Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar) final LinearLayout shape = (LinearLayout)findViewById(R.id.viewA) final ViewGroup.MarginLayoutParams vmlp = (ViewGroup.MarginLayoutParams) fab.getLayoutParams() shape.setVisibility(View.INVISIBLE) shape.setEnabled(false) setSupportActionBar(toolbar) String title = getIntent().getStringExtra("title") setTitle(title) fab.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { if (morph) { RotateAnimation ranim_close = new RotateAnimation(45f, 0f, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f) ranim_close.setFillAfter(true) ranim_close.setDuration(250L) fab.startAnimation(ranim_close) Animator animatorz = ViewAnimationUtils.createCircularReveal(shape, shape.getWidth() / 2, shape.getHeight(), (float) Math.hypot(shape.getWidth(), shape.getHeight()), 0) animatorz.setInterpolator(new AccelerateDecelerateInterpolator()) animatorz.setDuration(4000) animatorz.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation) shape.setVisibility(View.INVISIBLE) } }) animatorz.start() morph = false } else { RotateAnimation ranim_close = new RotateAnimation(0f, 45f, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f) ranim_close.setFillAfter(true) ranim_close.setDuration(250L) fab.startAnimation(ranim_close) Animator animator = ViewAnimationUtils.createCircularReveal(shape, shape.getWidth() / 2, shape.getHeight(), 0, (float) Math.hypot(shape.getWidth(), shape.getHeight())) shape.setVisibility(View.VISIBLE) animator.setInterpolator(new AccelerateDecelerateInterpolator()) if (shape.getVisibility() == View.VISIBLE) { animator.setDuration(4000) animator.start() morph = true }}}}) }}