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 ...
随机推荐
- miniui后台无法接收到input传值
出错原因:在miniui中,此处应写成<input textName="current_unit",在php中才可以使用$_POST['current_unit']获取到值, ...
- Objective-C总Runtime的那点事儿(一)消息机制
最近在找工作,Objective-C中的Runtime是经常被问到的一个问题,几乎是面试大公司必问的一个问题.当然还有一些其他问题也几乎必问,例 如:RunLoop,Block,内存管理等.其他的问题 ...
- java.lang.NoClassDefFoundError:org/apache/commons/lang/exception/NestableRuntimeException错误的解决
java.lang.NoClassDefFoundError 是运行时jvm找不到对应类.这种情况是少包的导致的.根据提示语添加对应的jar包就可以. 感叹一下:maven真是一个伟大的东西,在包的依 ...
- easyUi load方法重新加载表单的数据
1.表单回显数据的方法 <script> //方法一 function loadLocal(){ $('#ff').form('load',{ name:'myname', email:' ...
- Linux ip
工具/原料 linux系统 putty 方法/步骤 Linux下查看IP一般都是用命令在终端查看了,使用命令行来进行查看. 想要在图形界面查看的朋友也有办法,不过就比较复杂,不如一条命令来得痛 ...
- Solr学习总结(一)Solr介绍
最近一直在搞Solr的问题,研究Solr 的优化,搜索引擎的bug修改等,这几天终于有时间,闲下来总结分享,以便大家参考,与大家一起来共同学习. Solr是一个基于Lucene的全文搜索引擎,同 ...
- Android开发环境的搭建
在学习android时,环境的搭建是学习android的第一步,为了记住第一步特写了这篇文章. 第一步,安装jdk,因为eclipse的运行需要jdk才可以,所以jdk的安装时第一步.安装过程和普通的 ...
- html传参数
var request = { QueryString: function (paramName) { var url = window.location.search; paramValue = & ...
- krpano
调试: krpano的场景下方,有一个Console面板可以用来输出即时日志. 可以使用 showlog(true); 来设置打开此功能,默认是关闭的. 这样就可以把下面三种日志实时显示出来了: tr ...
- 【Solr】新建core后,启动服务访问web报错 HTTP Status 503
新建core collection2后,启动solr服务,访问solr web界面报错. HTTP Status 503 - Server is shutting down or failed to ...