kao*_*ick 6 animation android android-alertdialog material-design
我有Activity一个FloatingActionButton.当我按下FAB时,AlertDialog会显示一个.我想使用类似揭示从效果或弯曲运动,以动画它的外观Android的Material Design.该文档仅提供了更改现有视图可见性的示例.
我怎样才能实现这一目标AlertDialog?
如果您有自定义视图(在 XML 中定义),您可以尝试以下操作:
AlertDialog a = new AlertDialog.Builder(this)...blablabla;
View v = a.findViewById(R.layout.example);
// get the center for the clipping circle
int cx = (v.getLeft() + v.getRight()) / 2;
int cy = (v.getTop() + v.getBottom()) / 2;
// get the final radius for the clipping circle
int finalRadius = Math.max(v.getWidth(), v.getHeight());
// create the animator for this view (the start radius is zero)
Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius);
// make the view visible and start the animation
v.setVisibility(View.VISIBLE);
anim.start();
Run Code Online (Sandbox Code Playgroud)
要使用反向动画隐藏它:
View v = <yourAlertDialog>.findViewById(R.layout.example);
// get the center for the clipping circle
int cx = (v.getLeft() + v.getRight()) / 2;
int cy = (v.getTop() + v.getBottom()) / 2;
// get the initial radius for the clipping circle
int initialRadius = v.getWidth();
// create the animation (the final radius is zero)
Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, initialRadius, 0);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
v.setVisibility(View.INVISIBLE);
}
});
// start the animation
anim.start();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4547 次 |
| 最近记录: |