如何使移动的EditText由左到动画类型正确,反之亦然反之亦然、正确、类型、动画

2023-09-06 06:21:19 作者:自甘堕落

我已经做了验证按钮的EditText的onclick,如果是空的显示举杯说特定字段为空,除了希望的EditText得到它移动由左到右,反之亦然为动画形式,将有助于使应用程序的吸引力是否有可能?如果是的话,请帮我在此先感谢

i have done validation for edittext onclick of button and if it is empty will show a toast saying particular field empty and in addition want edittext to get it moved from left to right and vice versa as an animated form and will help to make app attractive Is it possible?? if so please help me thanks in advance

推荐答案

创建并写入以下内容动画/ shake.xml:

Create and Write following into 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" />

创建并写入以下内容动画/ cycle_7.xml:

Create and Write following into anim/cycle_7.xml:

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

现在使用动画类动画通过传递参数的任何视图。通过将所有视图调用此方法

now Use Animation class to animate any view by passing in argument. Call this method by passing any view

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();
}