Ответ 1
EDIT:
Я проверил это, сделав небольшое приложение
Прежде всего, скройте представление, которое вы хотите показать в этой анимации.
Вид может быть из одного и того же макета, а в xml его видимость должна быть невидимой, чтобы анимация отображала.
Вы можете установить высоту и ширину представления для match parent, если вы хотите создать полноэкранную анимацию ...
Возьмите свое оригинальное и открытое представление как в рамочном макете
В моем случае я использовал это:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:text="Hello World!"
android:layout_width="wrap_content"
android:textSize="20sp"
android:layout_height="wrap_content" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:id="@+id/revealiew"
android:visibility="invisible"
>
</FrameLayout>
то в вашей деятельности на button click
или в каком-либо событии выполните следующее:
fab.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onClick(View view) {
// previously invisible view
View myView = findViewById(R.id.revealview);
// get the center for the clipping circle
int cx = myView.getWidth() / 2;
int cy = myView.getHeight() / 2;
// get the final radius for the clipping circle
int finalRadius = Math.max(myView.getWidth(), myView.getHeight());
// create the animator for this view (the start radius is zero)
Animator anim =
ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
//Interpolator for giving effect to animation
anim.setInterpolator(new AccelerateDecelerateInterpolator());
// Duration of the animation
anim.setDuration(1000);
// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();
}
});
}
Подробную информацию о официальной документации можно найти здесь: http://developer.android.com/training/material/animations.html