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. javascript入门教程01

    1.javascript中变量的声明和赋值的三种方式 (1)先声明后赋值 var width; width=5; (2)同时声明和赋值变量 var width=5; var x,y,z=10; (3) ...

  2. mysql cmmand not found

    https://www.cnblogs.com/yangzigege/p/8337393.html

  3. GO判断输入

    判断用户密码输入: package main import"fmt" func main(){ var a int var b int fmt.Printf("请输入密码 ...

  4. Django:cookie和session相关问题

    http://www.cnblogs.com/fnng/p/3750596.html http://www.cnblogs.com/chenchao1990/p/5283725.html

  5. C++中的随机数

    事情的开始是这样的,在大二的时候,写了几种排序算法,为了测试,就要为数组(或者容器)赋予一些随机初值,自然就用到了C/C++中的随机函数. 当时为了调用简单,将随机数赋值的过程写到了一个单独的函数里, ...

  6. 重识线段树——Let's start with the start.

    声明 本文为 Clouder 原创,在未经许可情况下请不要随意转载.原文链接 前言 一般地,这篇文章是给学习过线段树却仍不透彻者撰写的,因此在某些简单的操作上可能会一笔带过. 当然了,入门线段树后也可 ...

  7. DRF项目之序列化器和视图重写方法的区别

    我们,都知道,DRF框架是一款高度封装的框架. 我们可以通过重写一些方法来实现自定义的功能. 今天,就来说说在视图中重写和序列化器中重写方法的区别. 在视图中重写方法: 接收请求,处理数据(业务逻辑) ...

  8. Flask - 请求扩展,钩子函数(Django的中间件) --> 请求前,中,后,

    例子1. 处理请求之前 @app.before_request 在请求之前,这个被装饰的函数会被执行 用户登录验证代码可以在这里写 @app.before_request def process_re ...

  9. kubernetes 使用flannel网络模式 错误分析

    今天按照网上和书上的要求,将目前的kubernetes网络换成flannel.其实配置起来还是很简单的,但是一旦出现了问题,将很难解决. 配置方法我这边不给出了.因为网上这样的教程一大把,在说下去也无 ...

  10. ypeError: __init__() got an unexpected keyword argument 'shape'

    采用TensorFlow支持通过tf.Graph函数来生成新的向量图,代码如下: import tensorflow as tf g1 = tf.Graph() with g1.as_default( ...