1.shake

animation_1.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip"
android:text="@string/animation_1_instructions"
/>
<EditText android:id="@+id/pw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:singleLine="true"
android:password="true"
/>
<Button android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/googlelogin_login"
/>
</LinearLayout>

shake.xml:(interpolator表示内插程序)

<?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:(cycles循环次数)

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

Animation1.java:

import com.example.android.apis.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils; public class Animation1 extends Activity implements View.OnClickListener { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animation_1); View loginButton = findViewById(R.id.login);
loginButton.setOnClickListener(this);
} public void onClick(View v) {
Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
findViewById(R.id.pw).startAnimation(shake);
} }

效果如图,输入密码,点击“Login”之后,输入框将会在一秒钟之内左右摇晃7个周期。

android中的简单animation(一)shake的更多相关文章

  1. android中的简单animation(四)3D transition

    animation_main_screen.xml: <?xml version="1.0" encoding="utf-8"?> <Fram ...

  2. android中的简单animation(三)accelerate(加速),decelerate(减速),anticipate,overshoot,bounce

    animation_3.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  3. android中的简单animation(二)push up,push left,cross fade,hyperspace

    animation_2.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  4. Android中xml设置Animation动画效果详解

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  5. MVP架构在xamarin android中的简单使用

    好几个月没写文章了,使用xamarin android也快接近两年,还有一个月职业生涯就到两个年了,从刚出来啥也不会了,到现在回头看这个项目,真jb操蛋(真辛苦了实施的人了,无数次吐槽怎么这么丑),怪 ...

  6. android中实现简单的聊天功能

    这个例子只是简单的实现了单机版的聊天功能,自己跟自己聊,啦啦~~ 主要还是展示RecyclerView控件的使用吧~ 参考我之前写的文章: android中RecyclerView控件的使用 andr ...

  7. Gradle在Android中的简单使用

    Gradle在Android中简单的使用 还望支持个人博客站:http://www.enjoytoday.cn Android Studio 使用gradle进行工程构建,为了更好的了解整个andro ...

  8. EventBus在Android中的简单使用

    EventBus是一个方便与Android中各组件通信的开源框架,开源地址;https://github.com/greenrobot/EventBus.EventBus功能非常强大 ,今天在做一个功 ...

  9. android 中Log - 简单使用

    例如,我们可以使用'Log.d'进行Debug,在java代码中输入Log.d(String tag, String message),tag为自己命名的tag,message为待输出的信息.然后打开 ...

随机推荐

  1. Java入门笔记 00-前言&目录

    前言:这本笔记记录的是Java基础部分的学习内容,大部分内容总结性的,包括: ---01 Java基础语法 ---02 数组 ---03 面向对象 ---04 异常处理 ---05 多线程 ---06 ...

  2. PAT A1103 Integer Factorization

    线性dfs,注意每次深搜完状态的维护~ #include<bits/stdc++.h> using namespace std; ; vector<int> v,tmp,pat ...

  3. 2020牛客寒假算法基础集训营4 J 二维跑步

    https://ac.nowcoder.com/acm/contest/view-submission?submissionId=43035417 假设有i步选择不动,就有n-i步移动 假设其中又有a ...

  4. Python 之网络编程之进程总体概要

     一: 进程的概念:(Process) 进程就是正在运行的程序,它是操作系统中,资源分配的最小单位. 资源分配:分配的是cpu和内存等物理资源 进程号是进程的唯一标识 同一个程序执行两次之后是两个进程 ...

  5. Derivative Pricing_1_Black

    1. Stock Option wih divends 1.1 Task A 1.1.1 Calculate a ECO on a stock. /Ex-dividend dates in 3 and ...

  6. WEB, Flask - Session&Cookie

    参考: https://blog.csdn.net/nunchakushuang/article/details/74652877 http://portal.xiaoxiangzi.com/Prog ...

  7. 中山Day10——普及

    今天又是愚蠢的一天,估分230,实得110.其中T2.4不会,这里就只说题意和简要思路. 收获:scanf>>a,以及printf<<a. T1:模板题 此题相对简单,就是读入 ...

  8. 用python发送qq邮件

    一.需要开启smtp服务,获取授权密码. 在qq邮箱的设置里开启smtp 二.代码 # -*- coding:utf-8 -*- import smtplib from email.mime.text ...

  9. NSNotFound

    1.在数组或者字典中查找元素时,没有查到系统用NSNotFound表示.比如下面例子,应该养成这种编程习惯,可以减少因为’超标’而闪退的情况. if ([self.departmentNameArra ...

  10. 阿里云CentOS安装图形化界面

    阿里云提供的linux系统是不含图形化界面的,如果您需要安装图形化界面, 请您参考为Linux实例安装图形化桌面环境和在CentOS系统中自动安装并运行VNC Server安装部署一下. 为Linux ...