android开门动画效果
来源:互联网 发布:php授权破解 编辑:程序博客网 时间:2024/04/19 19:08
- public class AntActivity extends Activity {
- private Context context;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- this.context = this;
- /***
- * 特别说明这两行代码,当加载一个布局文件的时候请使用以下方法导入。
- * 如导入main.xml这个布局文件的时候用以下方法。
- * 不要使用 以下代码 如
- * LinearLayout ll = (LinearLayout) this.findViewById(R.layout.main);
- * 因为main这个布局不是main.xml 文件下的一个布局,所以如果使用上一行代码的话 会报空指针的
- * 简单说,如果导入的是一个布局文件 那么使用LayoutInflater 如果加载的是一个布局文件中的子布局,使用findviewbyid()
- */
- LayoutInflater inflater = LayoutInflater.from(this);
- LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.main,null);
- /*****************************************************************************************/
- Animation animation = new TranslateAnimation(0, -getWindowManager().getDefaultDisplay().getWidth(), 0, 0);//向左移动的动画效果
- animation.setDuration(5000);//设置动画过程时间
- animation.setStartOffset(1000);//设置动画延时时间//一秒后开
- Animation animation1 = new TranslateAnimation(0,
- (float) (getWindowManager().getDefaultDisplay().getWidth()),0 ,0);//向右移动的动画效果
- animation1.setStartOffset(1000);
- animation1.setDuration(5000);
- final ImageView tt = new ImageView(this);
- tt.setLayoutParams(new LayoutParams(getWindowManager().getDefaultDisplay().getWidth()/2,
- getWindowManager().getDefaultDisplay().getHeight()));//设置改ImageView 的大小,宽为屏幕的一半,高为屏幕的高度
- //这样做的好处可以对不同屏幕分辨率进行适配
- tt.setBackgroundResource(R.drawable.tt_1);//设置背景
- final ImageView tt1 = new ImageView(this);
- tt1.setLayoutParams(new LayoutParams(getWindowManager().getDefaultDisplay().getWidth()/2,
- getWindowManager().getDefaultDisplay().getHeight()));
- tt1.setBackgroundResource(R.drawable.tt_2);
- tt1.setAnimation(animation1);//设置动画效果
- tt.setAnimation(animation);//设置动画效果
- animation.setAnimationListener(new Animation.AnimationListener() {//设置动画监听
- @Override
- public void onAnimationStart(Animation animation) {//动画状态开始
- // TODO Auto-generated method stub
- Toast.makeText(context, "I'm begin", 0).show();//日志提示开始了
- //如果想开们效果中出现锯齿效果,在动画开始时,在本位置,将ImageView 的背景置换一下就可以了
- }
- @Override
- public void onAnimationRepeat(Animation animation) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onAnimationEnd(Animation animation) {//动画状态结束
- // TODO Auto-generated method stub
- tt.setVisibility(View.GONE);//设置改控件隐藏,当然你也可以在结束这个位置放置其他处理。
- }
- });
- /**
- * 与上一个监听一样
- */
- animation1.setAnimationListener(new Animation.AnimationListener() {
- @Override
- public void onAnimationStart(Animation animation) {
- }
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
- @Override
- public void onAnimationEnd(Animation animation) {
- tt1.setVisibility(View.GONE);
- }
- });
- ll.addView(tt);
- ll.addView(tt1);
- this.setContentView(ll);//设置显示的布局内容
- }
- }
布局文件
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="horizontal" >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="@string/hello"
- android:visibility="gone" />
- </LinearLayout>
- android开门动画效果
- 43_实现开门动画效果
- css 开门-透视perspective动画效果
- android仿微信的开门效果
- 开门动画
- Android之高仿微信“开门动画”(六)
- android 实现微信的开门效果
- 学习COCOS2D-x 精灵动画 实现一个《热血传奇》开门效果
- 动画开源库:HMGLTransitions (WXHL) 3D动画切换, 开门效果等
- 开机动画开门效果实现中遇到的隐式动画问题
- android实现类似微信的开门效果
- android-微信引导图类似开门的效果
- 单侧开门动画
- 仿微信的开门效果
- HTC开门效果
- 仿微信的开门效果
- js实现开门效果
- Android动画---Animation动画效果
- ExtJS的使用
- ScrollView与ListView,GridView共存冲突解决办法 Android
- configure的制作
- ASP.NET中上传文件到数据库
- 2012/11/19——2012/11/23周记
- android开门动画效果
- 计算时间间隔天数
- 从客户端检测到有潜在危险的Request.Form值
- 异常:android.os.NetworkOnMainThreadException
- 揭秘淘宝286亿海量图片存储与处理架构
- WDF驱动模型
- Python快速入门
- MyEclipse中VSS的使用详解
- 为什么智能手机很重要(而老版的IE不再重要)