您的位置:首页 > 其它

左右晃动的动画

2016-06-08 11:39 141 查看
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">

    

    <!-- 画面转换位置一动效果 -->

    <translate

        android:duration="60"

        android:fromXDelta="5"

        android:toXDelta="-20"

        android:repeatMode="reverse"

        android:repeatCount="6"/>

</set>

/**

     * 左右晃动的动画

     *

     * @param ed

     * @param iv

     * @param context

     */

    public static void leftRightSwing(EditText ed, Context context) {

        Animation animation = AnimationUtils.loadAnimation(context,

                R.anim.edittext_swing);

        LinearInterpolator linearinterpolator = new LinearInterpolator();

        animation.setInterpolator(linearinterpolator);

        if (animation != null)

            ed.startAnimation(animation);

    }

    

    /**

     * 左右晃动的动画

     *

     * @param ed

     * @param iv

     * @param context

     */

    public static void leftRightSwing_two(TextView ed,ImageView iv ,Context context) {

        Animation animation = AnimationUtils.loadAnimation(context,

                R.anim.edittext_swing);

        LinearInterpolator linearinterpolator = new LinearInterpolator();

        animation.setInterpolator(linearinterpolator);

        if (animation != null)

            ed.startAnimation(animation);

        if (animation != null)

            iv.startAnimation(animation);

    }

    

    

    

    /**

     * 左右晃动的动画

     *

     * @param ed

     * @param iv

     * @param context

     */

    public static void leftRightSwing_three(RelativeLayout rl,Context context) {

        Animation animation = AnimationUtils.loadAnimation(context,

                R.anim.edittext_swing);

        LinearInterpolator linearinterpolator = new LinearInterpolator();

        animation.setInterpolator(linearinterpolator);

        if (animation != null)

            rl.startAnimation(animation);

    }
   

/**

     * 监听事件

     */

    private void addListener() {

        // 监听输入事件

        forget_paw_1.addTextChangedListener(new EditTextInputMonitor_1(

                forget_paw_del_1));

        forget_paw_2.addTextChangedListener(new EditTextInputMonitor(

                forget_paw_del_2));

        forget_paw_3.addTextChangedListener(new EditTextInputMonitor(

                forget_paw_del_3));

        forget_paw_4.addTextChangedListener(new EditTextInputMonitor(

                forget_paw_del_4));

        // 点击删除清空事件

        forget_paw_del_1.setOnClickListener(new EditTextDelMonitor(

                forget_paw_1, forget_paw_del_1));

        forget_paw_del_2.setOnClickListener(new EditTextDelMonitor(

                forget_paw_2, forget_paw_del_2));

        forget_paw_del_3.setOnClickListener(new EditTextDelMonitor(

                forget_paw_3, forget_paw_del_3));

        forget_paw_del_4.setOnClickListener(new EditTextDelMonitor(

                forget_paw_4, forget_paw_del_4));

        // 监听焦点事件

        forget_paw_1.setOnFocusChangeListener(new EditTextFocusMonitor(

                forget_paw_del_1, forget_paw_1));

        forget_paw_2.setOnFocusChangeListener(new EditTextFocusMonitor(

                forget_paw_del_2, forget_paw_2));

        forget_paw_3.setOnFocusChangeListener(new EditTextFocusMonitor(

                forget_paw_del_3, forget_paw_3));

        forget_paw_4.setOnFocusChangeListener(new EditTextFocusMonitor(

                forget_paw_del_4, forget_paw_4));

    }

   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: