如何添加应用程序启动图像中的Android手机? [英] How to Add Application StartUp Image in Android Mobile?
问题描述
我正在开发Android应用程序,它在那一刻,它加载的是Aplication,我只是有一个黑色的屏幕(直到应用程序获取其地位)。我想,当出现在黑屏显示全屏图像仿真器/ Android的手机。综观其他应用他们有公司标志或冷的形象,几秒钟弹出,有人可以告诉我如何做到这一点吗?
我用这个code:
I am developing an android app, which at the moment when it is loading the Aplication, I just have a black screen (until the app gets its footing).I want to display a full screen image when black screen appears on the Emulator/Android Mobile. Looking at other apps they have a company logo or cool image that pops up for a few seconds, can someone tell me how to do this please? I use this code:
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 view
setContentView(R.layout.activity_splash_screen);
final SplashScreen sPlashScreen = this;
// The thread to wait for splash screen events
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(3000);
}
}
catch(InterruptedException ex){
}
finish();
// Run next activity
Intent intent = new Intent();
intent.setClass(sPlashScreen, HomePage.class);
startActivity(intent);
}
};
mSplashThread.start();
}
/**
* Processes splash screen touch events
*/
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}
推荐答案
有关这一点,你必须设置开机画面...您还可以设置启动画面是这样的:
For this you have to set Splash Screen...You can also set Splash screen like this:
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// TODO Auto-generated method stub
finish();
Intent menu = new Intent(getBaseContext(), MainMenu.class);
startActivity(menu);
}
}, 3000);
}
}
这将设置初始屏幕只有3秒,然后你的主类将是展示......和XML的启动画面是这样的:
} It will set splash screen for just 3 seconds and then your Main class will be display...And XML for splash screen is like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash_screen">
希望这会帮助你...
Hope this will help you...
这篇关于如何添加应用程序启动图像中的Android手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!