animation_2.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"> <ViewFlipper android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:flipInterval=""
android:layout_marginBottom="20dip" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="26sp"
android:text="@string/animation_2_text_1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="26sp"
android:text="@string/animation_2_text_2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="26sp"
android:text="@string/animation_2_text_3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="26sp"
android:text="@string/animation_2_text_4"/>
</ViewFlipper> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:text="@string/animation_2_instructions"
/> <Spinner android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/> </LinearLayout>

push_up_in.xml(100%p表示相对于父控件100%):

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

push_up_out.xml:

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

push_left_in.xml:

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

push_left_out.xml:

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="300"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

Animation2.java:

 package com.example.android.apis.view;

 // Need the following import to get access to the app resources, since this
// class is in a sub-package.
import com.example.android.apis.R; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.ViewFlipper; public class Animation2 extends Activity implements
AdapterView.OnItemSelectedListener { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animation_2); mFlipper = ((ViewFlipper) this.findViewById(R.id.flipper));
mFlipper.startFlipping(); Spinner s = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, mStrings );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
s.setOnItemSelectedListener(this);
} public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
switch (position) { case 0:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_up_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_up_out));
break;
case 1:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.push_left_out));
break;
case 2:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
break;
default:
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
R.anim.hyperspace_in)); //hyperspace多维空间
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this,
R.anim.hyperspace_out));
break;
}
} public void onNothingSelected(AdapterView<?> parent) {
} private String[] mStrings = {
"Push up", "Push left", "Cross fade", "Hyperspace"}; private ViewFlipper mFlipper; }

显示效果如下,选择不同的显示方式,文字将会按照显示方式作不同的显示:

android中的简单animation(二)push up,push left,cross fade,hyperspace的更多相关文章

  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(一)shake

    1.shake animation_1.xml: <?xml version="1.0" encoding="utf-8"?> <Linear ...

  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中Intent具体解释(二)之使用Intent广播事件及Broadcast Receiver简单介绍

    通过第一篇的解说,我们已经看到了怎样使用Intent来启动新的应用程序组件,可是实际上他们也能够使用sendBroadcast方法来在组件间匿名的广播消息. 作为一个系统级别的消息传递机制,Inten ...

随机推荐

  1. faster-RCNN 加入新的Ground Truth

    出于project的需要,不仅要detect和classify对象,还希望建立不同class的对象之间的关系,进行所谓的pair-matching. 需要完成以下几步: 1. dataset中labe ...

  2. 使用python实现离散时间傅里叶变换

    以下内容引用链接:https://blog.csdn.net/baidu_37352210/article/details/79596633 (注意:通过如下内容可知,将序列信号进行傅里叶变换后,得到 ...

  3. elk安装2.0版本,自己总结,比较细致 es单机的安装

    用root用户会报错,版本6之前还是可以用root用户启动的,针对es的保护,数据的一些问题,6之后就不允许了. 启动成功 下面验证一下  可以直接用浏览器访问,接受http访问 配置,因为没有暴露端 ...

  4. 虚拟机安装CentOS详细操作

    使用VMware安装CentOS 6.4 环境:Windows7 ,VMware Workstation10,CentOS6.4 为什么选择CentOS ? 主流:目前的Linux操作系统主要应用于生 ...

  5. Activiti工作流数据库表结构

    Activiti工作流引擎数据库表结构 数据库表的命名 Acitiviti数据库中表的命名都是以ACT_开头的.第二部分是一个两个字符用例表的标识.此用例大体与服务API是匹配的. ACT_RE_*: ...

  6. 2019年5月6日A股两百点暴跌行情思考

    原因:特朗普推特发布贸易战消息 盘面:跳空低开,单边下跌,上证指数最大跌幅200点,收盘千股跌停 操作:开盘加仓,盘中加仓,尾盘满仓 总结: 特大黑天鹅事件爆发引发大盘暴跌时,后续必将迎来一个反弹机会 ...

  7. 搭建DHCP服务

    DHCP服务流程 1.DHCP客户端初次接入网络时,会发送DHCP发现报文(DHCP Discover),用于查找和定位DHCP服务器. 2.DHCP服务器在接收到DHCP发现报文后,发送DHCP提供 ...

  8. Java中使用JSONTokener判断接口返回字符串是JSONObject还是JSONArray

    今天在接口对接中,遇到一个问题,对方接口返回的JSONString,类型不确定,所以需要先做判断再进行处理.查阅资料后使用JSONTokener可进行处理,特此记录. String ret = ord ...

  9. SpringMVC 接收表单数据、数据绑定、解决请求参数中文乱码

    接收表单数据有3种方式. 1.使用简单类型接收表单数据(绑定简单数据类型) 表单: <form action="${pageContext.request.contextPath}/u ...

  10. vue通过路由传值及在页面刷新后如何保存值

    1.普通的路由跳转 方式一:通过routerLinkTo方式,转为a标签的跳转,to里面相当于a标签的href路径 如下: 方式二:通过this.$router.push方式: 如下: 2.带参数的路 ...