常见的系统动画
来源:互联网 发布:手机淘宝帐号注册流程 编辑:程序博客网 时间:2024/06/06 05:52
为方便开发人员,安卓提供了一些应用于视图的转换动画,可以在运行时用AnimationUtils类加载这些动画。
1、滑入和渐显
AnimationUtils.makeInAnimation(context, fromLeft); 第二个参数决定滑入的方向是左侧还是右侧
2、向上滑入和渐显
AnimationUtils.makeInChildBottomAnimation(context);
视图总是从屏幕的底部向上滑入
3、滑出和渐隐
AnimationUtils.makeOutAnimation(context, toRight);
第二个参数决定滑出的方向是左侧还是右侧
4、渐隐
AnimationUtils.loadAnimation(context, android.R.anim.fade_out); 直接加载系统的渐隐动画。
5、渐显
AnimationUtils.loadAnimation(context, android.R.anim.fade_in);直接加载系统的渐显动画。
这些变换动画只会临时改变视图的显示方式,如果需要永久显示或者隐藏需要结合Visibility参数
下面举个简单示例
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/main_btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="点击试试"/> <View android:layout_width="match_parent" android:layout_height="100dp" android:id="@+id/main_view" android:background="#CCC"/></LinearLayout>
Java代码:
public class MainActivity extends Activity implements OnClickListener{private View animateView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);animateView=findViewById(R.id.main_view);findViewById(R.id.main_btn).setOnClickListener(this);}@Overridepublic void onClick(View view) {if(animateView.getVisibility()==View.VISIBLE){Animation out=AnimationUtils.makeOutAnimation(this, true);//从右滑出animateView.startAnimation(out);animateView.setVisibility(View.INVISIBLE);}else {Animation in=AnimationUtils.makeInChildBottomAnimation(this);//底部滑入animateView.startAnimation(in);animateView.setVisibility(View.VISIBLE);}}}
0 0
- 常见的系统动画
- 几种常见的动画
- 常见的广告切换动画
- 常见的gif动画加载
- 常见的css3动画样式
- 常见的css3动画样式
- 常见的css3动画样式
- Android常见动画的使用
- ios 系统的动画
- 常见的系统进程
- 常见的系统命令
- 常见的嵌入式系统
- 常见的系统瓶颈
- 常见的iOS对动画的操作
- Unity动画系统-人形动画的导入
- 常见的动画效果(二)
- [转]常见的动画效果(二)
- 如何处理常见的gif动画
- gcc/g++ 实战之编译的四个过程
- I/O多路复用技术(multiplexing)
- Java.lang.String API笔记
- 《嫌疑人X的献身》读书笔记
- test
- 常见的系统动画
- 文本标签提取算法
- 数据挖掘算法二——svm
- 第六十八天学习笔记
- 《白夜行》读书笔记
- HTML5--内联SVG
- javascript——卡片切换
- js_for循环
- 面向对象——继承