android中的简单animation(一)shake
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的更多相关文章
- android中的简单animation(四)3D transition
animation_main_screen.xml: <?xml version="1.0" encoding="utf-8"?> <Fram ...
- android中的简单animation(三)accelerate(加速),decelerate(减速),anticipate,overshoot,bounce
animation_3.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...
- android中的简单animation(二)push up,push left,cross fade,hyperspace
animation_2.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...
- Android中xml设置Animation动画效果详解
在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...
- MVP架构在xamarin android中的简单使用
好几个月没写文章了,使用xamarin android也快接近两年,还有一个月职业生涯就到两个年了,从刚出来啥也不会了,到现在回头看这个项目,真jb操蛋(真辛苦了实施的人了,无数次吐槽怎么这么丑),怪 ...
- android中实现简单的聊天功能
这个例子只是简单的实现了单机版的聊天功能,自己跟自己聊,啦啦~~ 主要还是展示RecyclerView控件的使用吧~ 参考我之前写的文章: android中RecyclerView控件的使用 andr ...
- Gradle在Android中的简单使用
Gradle在Android中简单的使用 还望支持个人博客站:http://www.enjoytoday.cn Android Studio 使用gradle进行工程构建,为了更好的了解整个andro ...
- EventBus在Android中的简单使用
EventBus是一个方便与Android中各组件通信的开源框架,开源地址;https://github.com/greenrobot/EventBus.EventBus功能非常强大 ,今天在做一个功 ...
- android 中Log - 简单使用
例如,我们可以使用'Log.d'进行Debug,在java代码中输入Log.d(String tag, String message),tag为自己命名的tag,message为待输出的信息.然后打开 ...
随机推荐
- 字符流---Day32
时隔多久,我又回来写博客了,最近忙于两个课设,五周,搞得头发都不知道掉了多少根了,还没成为程序员就开始掉了,等我成为一名程序员的时候岂不是要秃头了,IT界的人会不会帮我当成大佬了,哈哈哈哈,希望我以后 ...
- 质因数分解(0)<P2012_1>
质因数分解 (prime.cpp/c/pas) [问题描述] 已知正整数n是两个不同的质数的乘积,试求出较大的那个质数. [输入] 输入文件名为prime.in. 输入只有一行,包含一个正整数n. [ ...
- notepad++常用命令
1>shift+tab减少缩进 2>tab键增加缩进 3>ctrol+d键复制多行 4>shift+alt+方向箭头,选中列 5>alt+c插入序列 6>ctrl+ ...
- mysql 连接数据库时时区报错
1.url: jdbc:mysql://192.168.0.101:3306/testdb?serverTimezone=UTC,在连接字符后面添加时区设置 2.使用navicat或者直接使用mysq ...
- Java1.7已经舍弃substr了
网上一堆在写substring和substr区别的文章,都是过时的. 起码在官方6.0的api文档中已经找不到了,只有substring()
- Vue - 监听页面刷新和关闭
一,在 created中 注册 页面刷新和关闭事件 created() { window.addEventListener('beforeunload', e => this.test(e)) ...
- YUV颜色编码格式
YUV 颜色编码采用的是 明亮度 和 色度 来指定像素的颜色,而色度又定义了颜色的两个方面:色调和饱和度. 其中: Y 表示明亮度(Luminance.Luma) U 和 V 表示色度(Chromin ...
- 61二叉搜索树的第k个结点
题目描述 给定一颗二叉搜索树,请找出其中的第k大的结点.例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4. 思路:二叉搜索树的中序遍历是递增的序列,使用 ...
- 详述ThreadLocal
ThreadLocal的作用和目的:用于实现线程内的数据共享,即对于相同的程序代码,多个模块在同一个线程中运行时要共享一份数据,而在另外线程中运行时又共享另外一份数据. 举一个反面例子,当我们使用简单 ...
- redis之Set(无序)类型常用方法总结
redis之Set(无序)类型常用方法总结 存--sadd key member [member ...] 取--SMEMBERS key sadd key member [member ...] 向 ...