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']获取到值, ...
- Codeforces Round #342 (Div. 2) C. K-special Tables(想法题)
传送门 Description People do many crazy things to stand out in a crowd. Some of them dance, some learn ...
- Node.js入门笔记(4):文件系统(fs)
文件系统(FileSystem) 文件系统模块 对于文件无外乎创建修改添加. File System - 文件系统模块 - require('fs') fs模块是核心模块,需要使用require导入后 ...
- zabbix3.0.4 邮件告警详细配置
sendEmail是一个轻量级,命令行的SMTP邮件客户端.如果你需要使用命令行发送邮件,那么sendEmail是非常完美的选择:使用简单并且功能强大.这个被设计用在php.bash perl和web ...
- MySql 杂记
1:声明一个int变量时,设置它默认为0,而不是空或null. int 型,取值范围-2,147,483,648 到 2,147,483,647 ,默认值是 0 int是值类型,读内存区间中指定长度单 ...
- Development of large-scale site performance optimization method from LiveJournal background
A LiveJournal course of development is a project in the 99 years began in the campus, a few people d ...
- PHP保留2位小数 格式化小数、浮点数
JS保留两位小数例子 四舍五入使用函数 toFixed() <html> <head> </head> <script language="java ...
- 利用Nginx实现域名转发 不修改主机头
在conf下 新建一个 文件 格式 : 域名.conf 例如:www.test.com.conf 文件里配置: server{ listen 80; server_name www.test.com ...
- php分页类
1.需求 学会php分页类的使用 2.参考例子 CI的分页类 3.代码部分 <?php class pagination{ public $pagesize=20; public $pagein ...
- React 还是 Vue: 你应该选择哪一个Web前端框架?
学还是要学的,用的多了,也就有更多的认识了,开发中遇到选择的时候也就简单起来了. 本文作者也做了总结: 如果你喜欢用(或希望能够用)模板搭建应用,请使用Vue 如果你喜欢简单和“能用就行”的东西 ...