如何使移动的EditText由左到动画类型正确,反之亦然 [英] how to make edittext move from left to right or vice versa in animation type

查看:186
本文介绍了如何使移动的EditText由左到动画类型正确,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了验证按钮的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();
}

这篇关于如何使移动的EditText由左到动画类型正确,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆