码迷,mamicode.com
首页 > 其他好文 > 详细

窗口抖动的实现

时间:2017-03-01 14:05:37      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:rom   ttext   led   save   抖动   list   click   utf-8   XML   

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>

 效果:

技术分享

窗口抖动的实现

标签:rom   ttext   led   save   抖动   list   click   utf-8   XML   

原文地址:http://www.cnblogs.com/loaderman/p/6483734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!