【发布时间】:2017-05-29 07:10:13
【问题描述】:
我在活动过渡上应用显示效果,当 startActivity 被称为通过显示效果显示的活动时。 Activity是注册Activity,包含3个editText、一个imageView和一个拍照按钮。
“问题是每当我选择或单击editText时,就会应用显示效果动画。”
动画应用于根布局,动画在 OnCreate 方法中启动,我也尝试通过其他生命周期方法(如 onStart 和 onResume 方法)应用动画,但它正在工作。
很高兴地接受了答案。 这是代码的快照。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_contact);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Name = (EditText) findViewById(R.id.enter_name_id);
Mobile = (EditText) findViewById(R.id.enter_mobile_id);
Email = (EditText) findViewById(R.id.enter_email_id);
imageView = (ImageView) findViewById(R.id.set_image);
LinearLayout rootview = (LinearLayout) findViewById(R.id.rootview);
rootview.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
{
@Override
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
{
float finalRadius=
(float)Math.hypot(v.getWidth(),v.getHeight());
int cx1 = (v.getLeft() + v.getRight()) / 2;
int cy1 = (v.getTop() + v.getBottom()) / 2;
Animator anim = ViewAnimationUtils.createCircularReveal(v,
cx1, cy1, 0, finalRadius);
anim.setDuration(1000);
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.start();
}
});
}
【问题讨论】:
标签: android android-layout animation