Android 控件的显示隐藏上下左右移动动画
一、利用Android提供的左右移动工具类:AnimationUtils
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
LinearLayout ll_first = (LinearLayout) findViewById(R.id.ll_first);LinearLayout ll_second = (LinearLayout) findViewById(R.id.ll_second);ll_first.setVisibility(View.GONE);ll_second.setVisibility(View.VISIBLE);// 向右边移出ll_first.setAnimation(AnimationUtils.makeOutAnimation(this, true));// 向右边移入ll_second.setAnimation(AnimationUtils.makeInAnimation(this, true));ll_first.setVisibility(View.VISIBLE);ll_second.setVisibility(View.GONE);// 向左边移入ll_first.setAnimation(AnimationUtils.makeInAnimation(this, false));// 向左边移出ll_second.setAnimation(AnimationUtils.makeOutAnimation(this, false)); |
二、用TranslateAnimation添加动画
先写一个AnimationUtil工具类:这里仅提供上下移动效果
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
public class AnimationUtil { private static final String TAG = AnimationUtil.class.getSimpleName(); /** * 从控件所在位置移动到控件的底部 * * @return */ public static TranslateAnimation moveToViewBottom() { TranslateAnimation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f); mHiddenAction.setDuration(500); return mHiddenAction; } /** * 从控件的底部移动到控件所在位置 * * @return */ public static TranslateAnimation moveToViewLocation() { TranslateAnimation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); mHiddenAction.setDuration(500); return mHiddenAction; }} |
隐藏的时候设置下动画就可以了
|
1
2
3
4
|
ll_first.setVisibility(View.GONE);ll_second.setVisibility(View.VISIBLE);ll_first.setAnimation(AnimationUtil.moveToViewBottom());ll_second.setAnimation(AnimationUtil.moveToViewLocation()); |
博客原文地址:http://www.cnblogs.com/liqw/p/4602876.html
Android 控件的显示隐藏上下左右移动动画的更多相关文章
- wpf image控件循环显示图片 以达到动画效果 问题及解决方案
1>最初方案: 用wpf的image控件循环显示图片,达到动画效果,其实就是在后台代码动态改变Image.Source的值,关键代码: ; i < ; i++)//六百张图片 { Bitm ...
- Android控件_TextView(显示文本框控件)
一.TextView控件的常用属性 1.android:id——控件的id 2.android:layout_width——设置控件的宽度 wrap_content(包裹实际文本内容) fill ...
- Android控件重叠显示小记
方案一 利用布局控件显示优先级 在xml中RelativeLayout,FrameLayout,靠后的控件显示在上层. 利用margin属性 margin属性可以控制控件间的距离,属性值为正值时,越大 ...
- winfrom 控件的显示隐藏方法
使用Panel作为容器 Panel2.Visible = true; //显示 Panel1.Visible = false; //隐藏
- HTML5学习总结-10 Android 控件WebView显示网页
WebView可以使得网页轻松的内嵌到app里,还可以直接跟js相互调用. webview有两个方法:setWebChromeClient 和 setWebClient 1)setWebClient: ...
- Android控件显示和隐藏
Android控件都有visibility属性,该属性有三个可能值:visible.invisible.gone.可以通过预设或是Java程序控制这些控件的显示或隐藏. 一.在XML配置文件设置 可见 ...
- [Android Pro] android控件ListView顶部或者底部也显示分割线
reference to : http://blog.csdn.net/lovexieyuan520/article/details/50846569 在默认的Android控件ListView在 ...
- Silverlight Visifire控件 .net后台控制aspx页面控件的显示与隐藏,动态给控件赋值,选定默认值的设定
.net后台代码: 控件的显示与隐藏: this.dateStart.Visibility = Visibility.Collapsed;//不显示控件 this.dateYear.Visibilit ...
- 安卓,网页控件,显示网页 Android, web controls, display web pages
安卓,网页控件,显示网页Android, web controls, display web pages 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq ...
随机推荐
- Docker使用
Docker使用注意 关于网络配置 在使用默认的桥接模式下,容器启动后会被分配一个与docker0在同一网段的地址,在容器内部默认显示为eth0,在宿主机上产生一个临时的vethXXX接口. 端口 ...
- 由于一个粗心造成的RuntimeException
今天在测试时候,老是有一个TextView报错,以下是错误日志: java.lang.RuntimeException: Unable to resume activity {com....Activ ...
- 防DDOS攻击SHELL脚本
最近一段时间服务器频繁遭到DDOS攻击,目前只能通过封IP来源来暂时解决.IP不源变化多端,光靠手工来添加简直是恶梦,想了个方法,用SHELL来做. 比较简单,但很实用:) 以下内容根据作者原文进行适 ...
- C#中的多态性
1.重载(overload) public void Sleep() { Console.WriteLine("Animal睡觉"); } public int Sleep(int ...
- [Unity3d]向量的过度方法以及拖尾效果
Vector3.RotateTowards() 用法 public static function RotateTowards(current: Vector3, target: Vector3, m ...
- 一次性事务和CTE插入数据的比较
有时要构造一些数据来做测试数据,像下面这样: IF OBJECT_ID(N'T14') IS NOT NULL BEGIN DROP TABLE T14 END GO CREATE TABLE T14 ...
- tyvj1192 迎春舞会之集体舞
背景 HNSDFZ的同学们为了庆祝春节,准备排练一场舞会. 描述 表演者排成n排,构成一个向前的正三角形(在屏幕上,即向下).而就每个人,他有可能正面朝前(小的向前正三角形).或向后三角形(小的向后正 ...
- codevs1228 苹果树
题目描述 Description 在卡卡的房子外面,有一棵苹果树.每年的春天,树上总会结出很多的苹果.卡卡非常喜欢吃苹果,所以他一直都精心的呵护这棵苹果树.我们知道树是有很多分叉点的,苹果会长在枝条的 ...
- [SQL] SQL学习笔记之基础操作
1 SQL介绍 SQL 是用于访问和处理数据库的标准的计算机语言.关于SQL的具体介绍,我们通过回答如下三个问题来进行. SQL 是什么? SQL,指结构化查询语言,全称是 Structured Qu ...
- Computer Vision: OpenCV, Feature Tracking, and Beyond--From <<Make Things See>> by Greg
In the 1960s, the legendary Stanford artificial intelligence pioneer, John McCarthy, famously gave a ...