Android:对于最低 SDK 版本 14,单击按钮后布局上的动画
Android: animation on layout after button clicked for minimum SDK version of 14
如何在最低 SDK 版本 14 应用程序中实现与 Android 完全相同的效果?
- 背景效果
- 滑动切换按钮
- 我的 minSDKVersion 是 14
背景是一个圆形的放大动画,还是有更具体的功能?
非常感谢...
对于您在示例中显示的内容,我没有具体的示例,但是您可以使用以下示例来接近:
您可以使用一个简单的 ToggleButton 作为开关。看这里:http://developer.android.com/guide/topics/ui/controls/togglebutton.html
对于波纹动画,请看一下这个 post: 那里有几个显示 "ripple" 效果的例子。您可以轻松地重复使用此动画,降低不透明度并将动画设置为更大视图的背景,如您的示例所示。
希望对您有所帮助!
复选框动画可以参考这个库Material Animation library for implementing background reveal animation and Toggle Button library。
看看Circular Reveal from touch point:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
if (view.getId() == R.id.square_yellow) {
revealFromCoordinates(motionEvent.getRawX(), motionEvent.getRawY());
}
}
return false;
}
private Animator animateRevealColorFromCoordinates(int x, int y) {
float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
viewRoot.setBackgroundColor(color);
anim.start();
}
对于任何感兴趣的人,我继续创建了一个演示应用程序,以使用两个开关的圆形显示来演示这种效果。您可以在这里下载。然而,它是 API 21 岁及以上。
如何在最低 SDK 版本 14 应用程序中实现与 Android 完全相同的效果?
- 背景效果
- 滑动切换按钮
- 我的 minSDKVersion 是 14
背景是一个圆形的放大动画,还是有更具体的功能?
非常感谢...
对于您在示例中显示的内容,我没有具体的示例,但是您可以使用以下示例来接近:
您可以使用一个简单的 ToggleButton 作为开关。看这里:http://developer.android.com/guide/topics/ui/controls/togglebutton.html
对于波纹动画,请看一下这个 post: 那里有几个显示 "ripple" 效果的例子。您可以轻松地重复使用此动画,降低不透明度并将动画设置为更大视图的背景,如您的示例所示。
希望对您有所帮助!
复选框动画可以参考这个库Material Animation library for implementing background reveal animation and Toggle Button library。
看看Circular Reveal from touch point:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
if (view.getId() == R.id.square_yellow) {
revealFromCoordinates(motionEvent.getRawX(), motionEvent.getRawY());
}
}
return false;
}
private Animator animateRevealColorFromCoordinates(int x, int y) {
float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
viewRoot.setBackgroundColor(color);
anim.start();
}
对于任何感兴趣的人,我继续创建了一个演示应用程序,以使用两个开关的圆形显示来演示这种效果。您可以在这里下载。然而,它是 API 21 岁及以上。