• 窗口抖动的实现


    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    import android.widget.EditText;
    
    public class AnimActivity extends Activity {
    	EditText edit;
    	Button btn;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            edit = (EditText)findViewById(R.id.edit);
            btn = (Button)findViewById(R.id.btn);
            btn.setOnClickListener(new View.OnClickListener() {
    			@Override
    			public void onClick(View v) {
    				Animation anim = AnimationUtils.loadAnimation(AnimActivity.this, R.anim.myanim);
    				edit.startAnimation(anim);
    			}
    		});
        }
    }
    

     在res/anim下创建cyle.xml

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

      在res/anim下创建myanim.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@anim/cycle" >
    
        <translate
            android:duration="300"
            android:fromXDelta="0"
            android:fromYDelta="0"
            android:toXDelta="-10"
            android:toYDelta="-10" />
        <translate
            android:duration="300"
            android:fromXDelta="0"
            android:fromYDelta="0"
            android:startOffset="300"
            android:toXDelta="10"
            android:toYDelta="-10" />
        <translate
            android:duration="300"
            android:fromXDelta="0"
            android:fromYDelta="0"
            android:startOffset="600"
            android:toXDelta="-10"
            android:toYDelta="10" />
        <translate
            android:duration="300"
            android:fromXDelta="0"
            android:fromYDelta="0"
            android:startOffset="900"
            android:toXDelta="10"
            android:toYDelta="10" />
    
    </set>
    

     mian.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <EditText
            android:layout_marginTop="100dp"
            android:id="@+id/edit"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="点击按钮、此窗口抖动" />
        <Button
            android:id="@+id/btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮" />
    </LinearLayout>
    

     效果:

  • 相关阅读:
    http://wpftoolkit.codeplex.com/t的使用方法
    WPF自定义控件Textbox 带水印 以及错误信息显示_02
    WPF自定义控件Textbox 带水印 以及错误信息显示
    WPF嵌入WORD文档
    WPF ObservableCollection 使用方法
    react 开发 next.js rn
    获取百度地图sdk
    使用rn如何在安卓App开发中去增删改查对数据进行本地操作和保存,利用插件【react-native-file-selector】UI体现上传文件,和react-native-fs,可以对本地文件进行操作
    python常见命令
    py 文件设置编码
  • 原文地址:https://www.cnblogs.com/loaderman/p/6483734.html
Copyright © 2020-2023  润新知