展会信息港展会大全

andriod启动菜单显示屏动画效果
来源:互联网   发布日期:2015-10-03 13:18:20   浏览:1595次  

导读:看到一个老外做的不错的android启动菜单的动画效果,小结下。1 首先在drawable目录下放一些动画要用的图片。2 splash.xml: LinearLayout xmlns:android=http://schemas.android.com/apk/res/android andr......

看到一个老外做的不错的android启动菜单的动画效果,小结下。

1 首先在drawable目录下放一些动画要用的图片。

2 splash.xml:

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android android:layout_width="wrap_content" android:layout_height="wrap_content"android:id="@+id/TheSplashLayout" android:layout_gravity="center" > < ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"android:id="@+id/SplashImageView" android:layout_gravity="center" >

3 点启动窗口动画效果后显示的main.xml

< TextView android:layout_width="fill_parent" android:layout_height="wrap_content"android:text="@string/hello" />

4 SplashScreen.java

这里是欢迎启动类的核心部分

public class SplashScreen extends Activity { /** * The thread to process splash screen events */private Thread mSplashThread;

/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Splash screen viewsetContentView(R.layout.splash); // Start animating the image final ImageView splashImageView = (ImageView) findViewById(R.id.SplashImageView); splashImageView.setBackgroundResource(R.drawable.flag); final AnimationDrawable frameAnimation = (AnimationDrawable)splashImageView.getBackground(); splashImageView.post( new Runnable(){ public void run() { frameAnimation.start(); } }); final SplashScreen sPlashScreen = this ; // The thread to wait for splash screen eventsmSplashThread = new Thread(){ @Override public void run(){ try { synchronized( this ){ //Wait given period of time or exit on touch wait(5000 ); } } catch (InterruptedException ex){ }finish(); // Run next activity Intent intent = new Intent(); intent.setClass(sPlashScreen, MainActivity. class ); startActivity(intent); stop(); } }; mSplashThread.start(); }@Override publicboolean onCreateOptionsMenu(Menu menu){ super .onCreateOptionsMenu(menu); returnfalse ; } /** * Processes splash screen touch events */ @Override public booleanonTouchEvent(MotionEvent evt) { if(evt.getAction() == MotionEvent.ACTION_DOWN) {synchronized (mSplashThread){ mSplashThread.notifyAll(); } } return true ; } 4 为了更好看,在values 目录下添加样式文件 styles.xml:注意下这里

赞助本站

人工智能实验室
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港