问题描述
我已经完成了edittext onclick按钮的验证,如果它是空的,则显示一个吐司,说明特定字段为空,并添加了Edittext将其从左到右移动,反之亦然是动画形式,并有助于制作应用吸引力是可能的吗?如果是的话,请提前帮助我感谢
推荐答案
以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" />
现在使用动画类通过传递参数来为任何视图进行动画.通过传递任何视图来调用此方法
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(); }
问题描述
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
推荐答案
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" />
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(); }
相关问答
相关标签/搜索