Android 动画1--View控件的显示和隐藏效果
16lz
2021-01-23
mShowAction = 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); mShowAction.setDuration(500);
隐藏动画
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);
View的显示:
view.startAnimation(mShowAction); view.setVisibility(View.VISIBLE);
View的隐藏:
view.startAnimation(mHiddenAction); view.setVisibility(View.GONE);
我们可以看下ImageView的显示:
ImageView imageView = (ImageView)findViewById(R.id.imageView1);Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade_in);imageView.setBackgroundResource(R.drawable.t);imageView.startAnimation(animation);
动画效果可以用xml文件定义,定义方法网上很多的,多多参考下。
更多相关文章
- 自定义按钮实现android 返回按钮 事件
- android自定义progressbar图片大小自适应
- android 自定义通知消息设置背景色不生效,导致部分机型显示白色字
- android 动画分类
- Android中intent如何传递自定义数据类型
- android 动画学习系列(一)