ViewSwitcher使用范例
一、简介
ViewSwitcher适用于两个视图带动画效果的切换。这里实现两个视图切换的功能,并附带滑屏效果。
二、截图
二、范例代码
带动画效果的切换视图一和视图二。
xml
<ViewSwitcher android:layout_alignParentBottom="true"
android:persistentDrawingCache="animation" android:id="@+id/bottom"
android:layout_width="match_parent" android:inAnimation="@android:anim/slide_in_left"
android:outAnimation="@android:anim/slide_out_right" android:layout_height="122.0dip">
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_marginBottom="12.0dip"
android:id="@+id/lyBottom" android:layout_height="wrap_content">
<Button android:id="@+id/btn_pre" android:text="上一步"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_toLeftOf="@+id/btn_middle"
android:layout_marginRight="150.0dip" />
<Button android:id="@+id/btn_middle" android:layout_width="wrap_content"
android:layout_centerInParent="true" android:onClick="onClick" android:visibility="invisible"
android:textSize="22.0sp"
android:layout_height="wrap_content"></Button>
<Button android:id="@+id/btn_next" android:text="下一步"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_toRightOf="@+id/btn_middle"
android:layout_marginLeft="150.0dip" />
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_gravity="bottom" android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView android:src="@drawable/cube" android:id="@+id/btn_reinsure"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="150.0dip"></ImageView>
<ImageView android:src="@drawable/cyddz" android:id="@+id/btn_identity"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btn_reinsure"
android:layout_marginLeft="124.0dip"></ImageView>
<ImageView android:src="@drawable/cykvmce" android:id="@+id/btn_insure_query"
android:layout_toRightOf="@+id/btn_identity" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginLeft="140.0dip"></ImageView>
<ImageView android:src="@drawable/m8gprs" android:id="@+id/btn_review"
android:layout_toRightOf="@+id/btn_insure_query"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="140.0dip"></ImageView>
<ImageView android:src="@drawable/th_appshareth"
android:layout_toRightOf="@+id/btn_review"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="130.0dip"></ImageView>
</RelativeLayout>
</ViewSwitcher>
代码说明:
1. 这里使用系统自带的切换效果@android:anim/slide_in_left和@android:anim/slide_out_right。
2. 请大家自行准备测试图片
java
bottom = (ViewSwitcher) findViewById(R.id.bottom);
//切换为第一个
bottom.setDisplayedChild(0);
//切换到下一个
//bottom.showNext()
ViewSwitcher使用范例的更多相关文章
- 二、Android应用的界面编程(七)ViewAnimator及其子类[ ViewSwitcher、ImageSwitcher、TextSwitcher、ViewFlipper ]
ViewAnimator是一个基类,它继承了FrameLayout.因此它表现出FrameLayout的特征,可以将多个View组“叠”在一起. ViewAnimator可以在View切换时表现出动画 ...
- C# 7.0 新功能代码范例
随着新版本的IDE Visual Studio 15 紧锣密鼓的开发中,2016年8月24日,微软发布了与之配套的C# 7.0 preview 的新特性. 其主要特性有: 内联声明out变量 (Out ...
- Information Management Policy(信息管理策略)的使用范例
基础知识 很多人都会定期收拾自己的书架或者抽屉,把里面过旧的资料拿走,为新的资料腾出空间来,这样既可以节省空间,而且当冗余资料过多的时候也会降低你查找的速度和效率.那么,在企业的SharePoint中 ...
- Java学习笔记13---一个循环程序的设计范例
package welcome; import java.util.Scanner; /* * 一个循环程序的设计范例 * 首先编写仅执行一次的程序(当无循环时) * 循环的设计步骤: * 1.确定程 ...
- [liusy.api-SMJ]-创建工程范例 MAVEN archetype 学习阶段(一)
由于这个架构需要好多不同能力的工程,为了创建方便减少冗余,创建工程范例尤为重要 学习阶段: 参考资料 http://maven.apache.org/archetype/maven-archetype ...
- 通过 UDP 发送数据的简单范例
package j2se.core.net.udp; import java.io.IOException;import java.net.DatagramPacket;import java.net ...
- 分享:写了一个 java 调用 C语言 开发的动态库的范例
分享:写了一个 java 调用 C语言 开发的动态库的范例 cfunction.h 代码#pragma once#ifdef __cplusplusextern "C" {#e ...
- [TypeScript] Dictionary范例
[TypeScript] Dictionary范例 Playground http://tinyurl.com/o7czcxo Samples class Dictionary { [index: s ...
- [转]Backbone.js简单入门范例
本文转自:http://dmyz.org/archives/598 11年刚开始用前端MVC框架时写过一篇文章,当时Knockout和Backbone都在用,但之后的项目全是在用Backbone,主要 ...
随机推荐
- 用Java开发代理服务器
基础知识 不管以哪种方式应用代理服务器,其监控HTTP传输的过程总是如下: 步骤一:内部的浏览器发送请求给代理服务器.请求的第一行包含了目标URL. 步骤二:代理服务器读取该URL,并把请求转发给合适 ...
- [前端 1] 使用frameset框架构建网页基本布局
导读:在做项目的过程中,发现网页的一些地方是不变的,比如说顶部.底部.而变幻的内容就只是一部分.这个时候在想,这是每次都刷新一个界面呢,还是有别的快捷方法呢.然后就找到了frameset 这个东西.本 ...
- 智能指针(三):unique_ptr使用简介
我们知道auto_ptr通过复制构造或者通过=赋值后,原来的auto_ptr对象就报废了.所有权转移到新的对象中去了.而通过shared_ptr可以让多个智能指针对象同时拥有某一块内存的访问权.但假如 ...
- SVN与TortoiseSVN实战:属性的奇技淫巧(一)
硬广:<SVN与TortoiseSVN实战>系列已经写了六篇,本系列结合TortoiseSVN对SVN中容易被忽视的部分进行了详解,预计再用三.四篇来结束这个系列. 本篇详解一下SVN的属 ...
- 有没有好用的开源sql语法分析器? - 匿名用户的回答 - 知乎
有没有好用的开源sql语法分析器? - 匿名用户的回答 - 知乎 presto,hive,drill,calcite,sparksq
- ios9和ios10的新特性
昨天面试了一个做ios开发的公司,其中面试官问我最新的ios系统版本是多少,以及它的特性是什么?由于自己是初学者,所以对这些没有关注过.今天特地搜索了一下关于ios9和ios10的新特性,并整理了一下 ...
- dreamweaver cs6 的破解方法
dreamweaver cs6 的破解方法,很简单大家照着下面的方法做肯定能破解方法/步骤 安装DreamWeaver cs6 使用amtlib.dll破解下载amtlib.dll文件后,解压后得到 ...
- 2016.04.09 使用Powerdesigner进行创建数据库的概念模型并转为物理模型
2016-04-09 21:10:24 本文原创受版权保护,严禁转载. 请大家不要用于商业用途,支持正版,大家都是做软件的,知道开发一套软件实属不易啊! 今天看到了一个很有趣并且很有用的辅助 ...
- jquery resize事件增强版
/* * jQuery resize event - v1.1 - 3/14/2010 * http://benalman.com/projects/jquery-resize-plugin/ * * ...
- Valid Parentheses [LeetCode 20]
1- 问题描述 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if ...