Android Listview切换动画,扩展到任意view切换之间动画实现
添加布局如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:text="切换按钮"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/list_en"
android:layout_width="match_parent"
android:layout_weight="1.0"
android:layout_height="0dip"/>
<ListView
android:id="@+id/list_fr"
android:layout_width="match_parent"
android:layout_weight="1.0"
android:layout_height="0dip"
android:visibility="gone"/>
</LinearLayout>
切换动画实现:
package com.edaixi.tempbak; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.Toast; @SuppressLint("NewApi")
public class SwitchListviewAnimation extends Activity { private static final int DURATION = 1500;
private SeekBar mSeekBar; private static final String[] LIST_STRINGS_EN = new String[] { "e 袋洗 - 1",
"e 袋洗 - 2", "e 袋洗 - 3", "e 袋洗 - 4", "e 袋洗 - 5", "e 袋洗 - 6" };
private static final String[] LIST_STRINGS_FR = new String[] { "阿姨帮 - 1",
"阿姨帮 - 2", "阿姨帮 - 3", "阿姨帮 - 4", "阿姨帮 - 5", "阿姨帮 - 6" }; ListView mEnglishList;
ListView mFrenchList; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_switch);
mEnglishList = (ListView) findViewById(R.id.list_en);
mFrenchList = (ListView) findViewById(R.id.list_fr); // Prepare the ListView
final ArrayAdapter<String> adapterEn = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, LIST_STRINGS_EN);
// Prepare the ListView
final ArrayAdapter<String> adapterFr = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, LIST_STRINGS_FR); mEnglishList.setAdapter(adapterEn);
mEnglishList.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
"---点击---" + LIST_STRINGS_EN[position], 0).show();
}
});
mFrenchList.setAdapter(adapterFr);
mFrenchList.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
"---点击---" + LIST_STRINGS_FR[position], 0).show();
}
});
mFrenchList.setRotationY(-90f); Button starter = (Button) findViewById(R.id.button);
starter.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
flipit();
}
});
} private Interpolator accelerator = new AccelerateInterpolator();
private Interpolator decelerator = new DecelerateInterpolator(); private void flipit() {
final ListView visibleList;
final ListView invisibleList;
if (mEnglishList.getVisibility() == View.GONE) {
visibleList = mFrenchList;
invisibleList = mEnglishList;
} else {
invisibleList = mFrenchList;
visibleList = mEnglishList;
}
ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList,
"rotationY", 0f, 90f);
visToInvis.setDuration(500);
visToInvis.setInterpolator(accelerator);
final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList,
"rotationY", -90f, 0f);
invisToVis.setDuration(500);
invisToVis.setInterpolator(decelerator);
visToInvis.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
visibleList.setVisibility(View.GONE);
invisToVis.start();
invisibleList.setVisibility(View.VISIBLE);
}
});
visToInvis.start();
} }
Android Listview切换动画,扩展到任意view切换之间动画实现的更多相关文章
- android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片)
首先我们还是看一些示例:(网易,新浪,百度) 显示效果都不错,可是手感就不一样了,百度最棒,网易还行,新浪就操作很不好,这里我说的是滑动切换图片.自己可以测试一下.不得不说牛叉的公司确实有哦牛叉的道理 ...
- 【转】Android android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片)
首先我们还是看一些示例:(网易,新浪,百度) 下面我简单的介绍下实现方法:其实就是listview addHeaderView.只不过这个view是一个可以切换图片的view,至于这个vie ...
- Android ListView动画特效实现原理及源代码
Android 动画分三种,当中属性动画为我们最经常使用动画,且能满足项目中开发差点儿所有需求,google官方包支持3.0+.我们能够引用三方包nineoldandroids来失陪到低版本号.本样例 ...
- Android View的滑动 动画
[scrollTo/scrollBy] //控件内的文字会移动,但是控件本身不会移动,而且移动到控件之外之后,文字也就看不见了 if(v.equals(button2)){ button2.scrol ...
- 浅谈Android样式开发之View Animation (视图动画)
引言 一个用户体验良好的App肯定少不了动画效果.Android为我们提供了2种动画框架,分别是视图动画(View Animation)和属性动画(Property Animation).视图动画比较 ...
- android任意view爆炸效果--第三方开源--ExplosionField
犹如天女散花一样,爆炸散列,比较有趣.Android ExplosionField在github上的项目主页是:https://github.com/tyrantgit/ExplosionField ...
- Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation
程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...
- Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)
1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...
- Android动画之二:View Animation
作为一个博客<Android其中的动画:Drawable Animation>.android动画主要分为三大部分.上一篇博客已经解说Drawable Animation的使用方法,即逐帧 ...
随机推荐
- 【整理】SQLServer查询各种数据库对象(表,索引,视图,图表,存储过程等)
首先明确数据库对象的定义:数据库对象定义数据库内容的结构.它们包含在数据库项目中,数据库项目还可以包含数据生成计划和脚本. 常见的数据库对象包括:表,索引,视图,图表,缺省值,规则,触发器,存储过程, ...
- iOS极光推送的基本使用
昨天花了一下午的时间研究了下极光推送,也前也是没做过,不知道从何下手!才开始的时候一看官方的SDK感觉好难,不过经过一系列的捣鼓之后,手机收到了推送信息,感觉其实并没有那么难! 1.配置开发证书(得有 ...
- shared_ptr智能指针源码剖析
(shared_ptr)的引用计数本身是安全且无锁的,但对象的读写则不是,因为 shared_ptr 有两个数据成员,读写操作不能原子化.根据文档 (http://www.boost.org/doc/ ...
- C语言统计运行时间
clock()是C/C++中的计时函数,而与其相关的数据类型是clock_t. 在MSDN中,查得对clock函数定义如下: clock_t clock(void) ; 简单而言,就是该程序从启动 ...
- Android studio 查看sha1
高德地图开发申请KEY的时候需要开发者提供SHA1证书指纹数据,在eclipse很容易就找到了,但是Android Studio很久也没找到,只能使用在网上看到的方法了,在Android Studio ...
- GO语言搭建
最近对GO语言产生了浓厚的兴趣.因为GO语言不仅仅可以开发桌面.web程序,最吸引我的是安卓大有往GO语言全方位靠拢的趋势,自家的系统还是用自家的语言开发比较靠谱. 用一句话来说:Go语言是谷歌200 ...
- 看IT牛人博客的哲理
潜意识追求复杂的东西 想着用C语言包揽所有的事情 对于不同问题,不同领域 各种技术和方案都有着自己最为优势的解决方法 对要解决的问题的领域的理解很重要
- QT连接mysql中文显示问题
亲测OK! #vim /etc/mysql/my.cnf [mysqld]下面加入: default-character-set=utf8 重启mysql /etc/init.d/mysql rest ...
- Linux中的cron计划任务配置方法(详细)
cron来源于希腊单词chronos(意为“时间”),指Linux系统下一个自动执行指定任务的程序(计划任务) 1. crontab命令选项 #crontab -u <-l, -r, -e> ...
- Cortex-M3学习日志(二)-- 按键实验
有输出总会有输入,今天测试一下按键的功能,第一节已经说过了与GPIO端口相关的寄存器,这里不在重复,想要从端口读取数据,首先把FIODIR这个寄存器设置为输入,再从FIOPIN寄存器读取数据就可以了, ...