Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我需要做一个喷溅屏幕_Android_Sdk - Fatal编程技术网

Android 我需要做一个喷溅屏幕

Android 我需要做一个喷溅屏幕,android,sdk,Android,Sdk,在iOS中,我会这样做: splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 768, 1024)]; splashView.image = [UIImage imageNamed:@"Default.png"]; [window addSubview:splashView]; [window bringSubviewToFront:splashView]; [UIView beginAnimations:ni

在iOS中,我会这样做:

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 768, 1024)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.5];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -60, 900, 1200);
[UIView commitAnimations];
然后“推”视图控制器继续

我已经看过了各种示例和教程,无法理解需要哪些代码来:

  • 显示屏幕
  • 让它淡出
  • 显示另一个视图(操作?)
  • 一些人发布了我修改过的代码,但是注释过的代码产生了一个错误。我一定错过了什么。

    公共类SplashScreen扩展活动{
    
    public class SplashScreen extends Activity {
    protected boolean _active = true;
    protected int _splashTime = 3000;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash);
    
        // thread for displaying the SplashScreen
        Thread splashTread = new Thread() {
            @Override
            public void run() {
                try {
                    int waited = 0;
                    while (_active && (waited < _splashTime)) {
                        sleep(100);
                        if (_active) {
                            waited += 100;
                        }
                    }
                } catch (InterruptedException e) {
                    // do nothing
                } finally {
                    finish();
                    startActivity(new Intent(
                            "com.android.NextActivity"));
                }
            }
        };
        splashTread.start();
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            _active = false;
        }
        return true;
    }
    
    受保护布尔值_active=true; 受保护的时间=3000; /**在首次创建活动时调用*/ @凌驾 创建时的公共void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE\u NO\u TITLE); setContentView(R.layout.splash); //用于显示屏幕的线程 螺纹飞溅踏板=新螺纹(){ @凌驾 公开募捐{ 试一试{ int=0; while(_active&&(waiting<_splashTime)){ 睡眠(100); 如果(_活动){ 平均值+=100; } } }捕捉(中断异常e){ //无所事事 }最后{ 完成(); 星际触觉(新意图)( “com.android.nextractivity”); } } }; splashTread.start(); } @凌驾 公共布尔onTouchEvent(运动事件){ if(event.getAction()==MotionEvent.ACTION\u向下){ _主动=假; } 返回true; }
    }

    和splash.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"  >
    <ImageView android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:src="@drawable/your_image_here" />
    </LinearLayout>
    
    
    
    在这方面我帮不了你,只是建议没有人喜欢闪屏,你真的不应该费心去做闪屏。这是一个用户可能会忽略或有点恼火的特性。这里有很多例子,谢谢你的回答,但请原谅我的无知。我知道在项目中包含splash.xml的位置,但我不确定其他代码属于何处。
    splash.xml->/layout
    ,在->
    SplashScreen.java
    中的代码,您必须创建一个文件。然后,您当然必须将清单中的活动声明为