Android实现EditText的抖动效果

在写文章之前提一下samples,里面有很多Android初学者可以学的东西,本文的效果也是来自其中。
在这里插入图片描述
其实samples在AS中的模拟器中就有展示的效果(API Demos)
在这里插入图片描述
代码如下:
java文件中代码调用:

Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake);
mEtPhone.startAnimation(shake);

shake.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<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文件:

<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />

欢迎留言

发布了77 篇原创文章 · 获赞 411 · 访问量 27万+

猜你喜欢

转载自blog.csdn.net/qq_42761395/article/details/100535526