添加布局如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Copyright (C) 2010 The Android Open Source Project
  3.  
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7.  
  8. http://www.apache.org/licenses/LICENSE-2.0
  9.  
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16.  
  17. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  18. android:orientation="vertical"
  19. android:layout_width="match_parent"
  20. android:layout_height="match_parent">
  21. <Button
  22. android:id="@+id/button"
  23. android:text="切换按钮"
  24. android:layout_width="wrap_content"
  25. android:layout_height="wrap_content" />
  26. <ListView
  27. android:id="@+id/list_en"
  28. android:layout_width="match_parent"
  29. android:layout_weight="1.0"
  30. android:layout_height="0dip"/>
  31. <ListView
  32. android:id="@+id/list_fr"
  33. android:layout_width="match_parent"
  34. android:layout_weight="1.0"
  35. android:layout_height="0dip"
  36. android:visibility="gone"/>
  37. </LinearLayout>

  

切换动画实现:

  1. package com.edaixi.tempbak;
  2.  
  3. import android.animation.Animator;
  4. import android.animation.AnimatorListenerAdapter;
  5. import android.animation.ObjectAnimator;
  6. import android.annotation.SuppressLint;
  7. import android.app.Activity;
  8. import android.os.Bundle;
  9. import android.view.View;
  10. import android.view.animation.AccelerateInterpolator;
  11. import android.view.animation.DecelerateInterpolator;
  12. import android.view.animation.Interpolator;
  13. import android.widget.AdapterView;
  14. import android.widget.AdapterView.OnItemClickListener;
  15. import android.widget.ArrayAdapter;
  16. import android.widget.Button;
  17. import android.widget.ListView;
  18. import android.widget.SeekBar;
  19. import android.widget.Toast;
  20.  
  21. @SuppressLint("NewApi")
  22. public class SwitchListviewAnimation extends Activity {
  23.  
  24. private static final int DURATION = 1500;
  25. private SeekBar mSeekBar;
  26.  
  27. private static final String[] LIST_STRINGS_EN = new String[] { "e 袋洗 - 1",
  28. "e 袋洗 - 2", "e 袋洗 - 3", "e 袋洗 - 4", "e 袋洗 - 5", "e 袋洗 - 6" };
  29. private static final String[] LIST_STRINGS_FR = new String[] { "阿姨帮 - 1",
  30. "阿姨帮 - 2", "阿姨帮 - 3", "阿姨帮 - 4", "阿姨帮 - 5", "阿姨帮 - 6" };
  31.  
  32. ListView mEnglishList;
  33. ListView mFrenchList;
  34.  
  35. /** Called when the activity is first created. */
  36. @Override
  37. public void onCreate(Bundle savedInstanceState) {
  38. super.onCreate(savedInstanceState);
  39. setContentView(R.layout.activity_switch);
  40. mEnglishList = (ListView) findViewById(R.id.list_en);
  41. mFrenchList = (ListView) findViewById(R.id.list_fr);
  42.  
  43. // Prepare the ListView
  44. final ArrayAdapter<String> adapterEn = new ArrayAdapter<String>(this,
  45. android.R.layout.simple_list_item_1, LIST_STRINGS_EN);
  46. // Prepare the ListView
  47. final ArrayAdapter<String> adapterFr = new ArrayAdapter<String>(this,
  48. android.R.layout.simple_list_item_1, LIST_STRINGS_FR);
  49.  
  50. mEnglishList.setAdapter(adapterEn);
  51. mEnglishList.setOnItemClickListener(new OnItemClickListener() {
  52.  
  53. @Override
  54. public void onItemClick(AdapterView<?> parent, View view,
  55. int position, long id) {
  56. Toast.makeText(getApplicationContext(),
  57. "---点击---" + LIST_STRINGS_EN[position], 0).show();
  58. }
  59. });
  60. mFrenchList.setAdapter(adapterFr);
  61. mFrenchList.setOnItemClickListener(new OnItemClickListener() {
  62.  
  63. @Override
  64. public void onItemClick(AdapterView<?> parent, View view,
  65. int position, long id) {
  66. Toast.makeText(getApplicationContext(),
  67. "---点击---" + LIST_STRINGS_FR[position], 0).show();
  68. }
  69. });
  70. mFrenchList.setRotationY(-90f);
  71.  
  72. Button starter = (Button) findViewById(R.id.button);
  73. starter.setOnClickListener(new View.OnClickListener() {
  74. public void onClick(View v) {
  75. flipit();
  76. }
  77. });
  78. }
  79.  
  80. private Interpolator accelerator = new AccelerateInterpolator();
  81. private Interpolator decelerator = new DecelerateInterpolator();
  82.  
  83. private void flipit() {
  84. final ListView visibleList;
  85. final ListView invisibleList;
  86. if (mEnglishList.getVisibility() == View.GONE) {
  87. visibleList = mFrenchList;
  88. invisibleList = mEnglishList;
  89. } else {
  90. invisibleList = mFrenchList;
  91. visibleList = mEnglishList;
  92. }
  93. ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList,
  94. "rotationY", 0f, 90f);
  95. visToInvis.setDuration(500);
  96. visToInvis.setInterpolator(accelerator);
  97. final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList,
  98. "rotationY", -90f, 0f);
  99. invisToVis.setDuration(500);
  100. invisToVis.setInterpolator(decelerator);
  101. visToInvis.addListener(new AnimatorListenerAdapter() {
  102. @Override
  103. public void onAnimationEnd(Animator anim) {
  104. visibleList.setVisibility(View.GONE);
  105. invisToVis.start();
  106. invisibleList.setVisibility(View.VISIBLE);
  107. }
  108. });
  109. visToInvis.start();
  110. }
  111.  
  112. }

  

Android Listview切换动画,扩展到任意view切换之间动画实现的更多相关文章

  1. android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片)

    首先我们还是看一些示例:(网易,新浪,百度) 显示效果都不错,可是手感就不一样了,百度最棒,网易还行,新浪就操作很不好,这里我说的是滑动切换图片.自己可以测试一下.不得不说牛叉的公司确实有哦牛叉的道理 ...

  2. 【转】Android android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片)

    首先我们还是看一些示例:(网易,新浪,百度)      下面我简单的介绍下实现方法:其实就是listview addHeaderView.只不过这个view是一个可以切换图片的view,至于这个vie ...

  3. Android ListView动画特效实现原理及源代码

    Android 动画分三种,当中属性动画为我们最经常使用动画,且能满足项目中开发差点儿所有需求,google官方包支持3.0+.我们能够引用三方包nineoldandroids来失陪到低版本号.本样例 ...

  4. Android View的滑动 动画

    [scrollTo/scrollBy] //控件内的文字会移动,但是控件本身不会移动,而且移动到控件之外之后,文字也就看不见了 if(v.equals(button2)){ button2.scrol ...

  5. 浅谈Android样式开发之View Animation (视图动画)

    引言 一个用户体验良好的App肯定少不了动画效果.Android为我们提供了2种动画框架,分别是视图动画(View Animation)和属性动画(Property Animation).视图动画比较 ...

  6. android任意view爆炸效果--第三方开源--ExplosionField

    犹如天女散花一样,爆炸散列,比较有趣.Android ExplosionField在github上的项目主页是:https://github.com/tyrantgit/ExplosionField ...

  7. Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation

    程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...

  8. Android动画总结#补间动画(Tween Animation/View Animation) #帧动画(Frame Animation/Drawable Animation)#属性动画(PropertyAnimation)

    1.共有三种动画,英文名字多种叫法如下 第一种动画:补间动画(Tween Animation/View Animation) 四个:RotateAnimation旋转. AlphaAnimation透 ...

  9. Android动画之二:View Animation

    作为一个博客<Android其中的动画:Drawable Animation>.android动画主要分为三大部分.上一篇博客已经解说Drawable Animation的使用方法,即逐帧 ...

随机推荐

  1. Android之ActionBar学习

    关于那个问题:是关于如何生成如下图所示之ActionBar效果: 其实就在官网上就有答案,自己疏忽再加上资料繁多.寻了许久,经过指点.终于找到: To enable split action bar, ...

  2. OC中给我们提供的一个技术:谓词(NSPredicate).note

    OC中给我们提供的一个技术:谓词(NSPredicate)OC中的谓词操作是针对于数组类型的,他就好比数据库中的查询操作,数据源就是数组,这样的好处是我们不需要编写很多代码就可以去操作数组,同时也起到 ...

  3. Java学习之Java实现CallBack功能

    回调函数实际上就是在调用某个函数(通常是API函数)时,将自己的一个函数(这个函数为回调函数)的地址作为参数传递给那个函数.而那个函数在需要的时候,利用传递的地址调用回调函数,这时你可以利用这个机会在 ...

  4. Arduino周边模块:LED部件

    Arduino周边模块:LED部件 Arduino周边模块:LED部件 1. LED的使用 LED的原理: LED是会发光的二极管,它具有单向导电性.两端加上正向电压,即能将电能转化为光能. 正向电压 ...

  5. UIWebViewでローカルにあるHTMLを表示する&iOS6からtextAlignmentで指定する値が変更になった

    [objective-c]UIWebViewでローカルにあるHTMLを表示する xcode内にHTMLを格納して.そのHTMLをWebViewで表示する方法です. // UIWebViewの初期化UI ...

  6. php中如何输出当前服务器的(中国)当前时间

    date_default_timezone_set('PRC');//PRC是什么?PRC是中华人民共和国啊-_- echo "今天是".date("Y年m月d日&quo ...

  7. php数据类型有哪些?

    php数据类型有哪些?有三大类1.基本数据类型 1.1整型 $a = 0123; // 八进制数(是以0开头) 83 $a = 0x1A; // 十六进制数              26 1.2小数 ...

  8. Blast使用详解

    Blast,全称Basic Local Alignment Search Tool,即"基于局部比对算法的搜索工具",由Altschul等人于1990年发布.Blast能够实现比较 ...

  9. struts2笔记04-XxxAware接口

    1.XxxAware接口 ApplicationAware, RequestAware,SessionAware, ParameterAware.      struts2提供了这四个Aware接口用 ...

  10. 强制删除正在连接的Oracle用户,以删除SDE用户为例

    . 有时候想强制删除一个已经连接的Oracle用户,不能直接删除,可以用Kill会话信息. 比如今天想删除一个被连接的SDE用户,可以用以下方法删除一个“正在被连接”的用户. 1.查看所有用户的会话信 ...