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的使用方法,即逐帧 ...
随机推荐
- Android之ActionBar学习
关于那个问题:是关于如何生成如下图所示之ActionBar效果: 其实就在官网上就有答案,自己疏忽再加上资料繁多.寻了许久,经过指点.终于找到: To enable split action bar, ...
- OC中给我们提供的一个技术:谓词(NSPredicate).note
OC中给我们提供的一个技术:谓词(NSPredicate)OC中的谓词操作是针对于数组类型的,他就好比数据库中的查询操作,数据源就是数组,这样的好处是我们不需要编写很多代码就可以去操作数组,同时也起到 ...
- Java学习之Java实现CallBack功能
回调函数实际上就是在调用某个函数(通常是API函数)时,将自己的一个函数(这个函数为回调函数)的地址作为参数传递给那个函数.而那个函数在需要的时候,利用传递的地址调用回调函数,这时你可以利用这个机会在 ...
- Arduino周边模块:LED部件
Arduino周边模块:LED部件 Arduino周边模块:LED部件 1. LED的使用 LED的原理: LED是会发光的二极管,它具有单向导电性.两端加上正向电压,即能将电能转化为光能. 正向电压 ...
- UIWebViewでローカルにあるHTMLを表示する&iOS6からtextAlignmentで指定する値が変更になった
[objective-c]UIWebViewでローカルにあるHTMLを表示する xcode内にHTMLを格納して.そのHTMLをWebViewで表示する方法です. // UIWebViewの初期化UI ...
- php中如何输出当前服务器的(中国)当前时间
date_default_timezone_set('PRC');//PRC是什么?PRC是中华人民共和国啊-_- echo "今天是".date("Y年m月d日&quo ...
- php数据类型有哪些?
php数据类型有哪些?有三大类1.基本数据类型 1.1整型 $a = 0123; // 八进制数(是以0开头) 83 $a = 0x1A; // 十六进制数 26 1.2小数 ...
- Blast使用详解
Blast,全称Basic Local Alignment Search Tool,即"基于局部比对算法的搜索工具",由Altschul等人于1990年发布.Blast能够实现比较 ...
- struts2笔记04-XxxAware接口
1.XxxAware接口 ApplicationAware, RequestAware,SessionAware, ParameterAware. struts2提供了这四个Aware接口用 ...
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
. 有时候想强制删除一个已经连接的Oracle用户,不能直接删除,可以用Kill会话信息. 比如今天想删除一个被连接的SDE用户,可以用以下方法删除一个“正在被连接”的用户. 1.查看所有用户的会话信 ...