如何使edittext在动画类型中从左向右移动,反之亦然

时间:2013-04-15 10:31:24

标签: android

我已经完成了edittext onclick按钮的验证,如果它是空的,将显示一个toast说特定字段为空,另外想要edittext将它从左向右移动,反之亦然作为动画形式,将有助于制作app有吸引力有可能??如果是这样,请提前帮助我

1 个答案:

答案 0 :(得分:7)

创建并写入anim / shake.xml:

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="10" android:duration="1000"
    android:interpolator="@anim/cycle_7" />

在anim / cycle_7.xml中创建并编写以下内容:

<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />

现在使用Animation类通过传入参数为任何视图设置动画。通过传递任何视图

来调用此方法
public void onShake(View v, String your_msg) {
    Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
    findViewById(R.id.pw).startAnimation(shake);
    Toast.makeText(this, your_msg, Toast.LENGTH_SHORT).show();
}
相关问题