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为待输出的信息.然后打开 ...
随机推荐
- 04在eclipse当中使用gitee
一.使用Bash连接GitHub时作了哪些事情 1.生成公钥 2.在GitHub上配置SSHKEY 3.创建关联 4.关联远程仓库 5.向远程仓库推送数据 6.拉取数据 二.把项目分享到gitee ...
- 笔记-twisted源码-import reactor解析
笔记-twisted源码-import reactor解析 1. twisted源码解析-1 twisted reactor实现原理: 第一步: from twisted.internet ...
- JS经典理解例子
1. var name = 'the window'; var obj = { name:"my obj", getNameFunc:function(){ return func ...
- 吴裕雄--天生自然ORACLE数据库学习笔记:常用SQL*Plus命令
set pause on set pause '按<enter>键继续' select user_id,username,account_status from dba_users; sh ...
- STM32单片机的软件重启和远程重启
STM32单片机可以通过以下代码实现重启(core_cm3.h).同时如果利用AT命令进行无线通讯,服务器后台和客户端之间用MODBUS通讯即4G+MODBUS RTU,可以利用F05写单个线圈的方法 ...
- 捣鼓FileZilla
今天突然对ftp服务器感兴趣,于是随意打了一个ftp词条,发现了FZ官网,好奇点进去下载了之后,捣鼓了一会.于是,也写一个小教程记录一下吧,害怕自己以后忘记怎么弄的了. 首先需要用到两个,一个是FZ ...
- [Qt5] 使用Qt设计器绘制主窗口
实践代码: git clone https://github.com/dilexliu/learn_qt5.git Step1: Qt设计器绘制窗口 保存会得到一个文件: mainwindow.ui ...
- 新增6 n个骰子的点数
/* * * 面试题43:n个骰子的点数 * 把n个骰子扔在地上,所有骰子朝上一面的点数之和为s. * 输入n,打印出s的所有可能的值出现的概率. * */ #include <iostream ...
- Go 开发者平均年薪 46 万?爬数据展示国内 Go 的市场行情到底如何
随着云原生时代的到来,拥有高并发性.语法易学等特点的 Golang 地位逐渐凸显,在云原生编程中占据了主导地位.在近期出炉的 TIOBE 10 月编程语言排行榜中,Golang 从前一个月的 16 位 ...
- 如何查看python的notebook文件.ipynb
文章中的ipython notebook和jupyter notebook基本可以互换,不过使用ipython notebook会警告您要使用jupyter notebook.其他没有区别. ---- ...