gpt4 book ai didi

java - 如何在 Android 应用程序上放置闪屏?

转载 作者:行者123 更新时间:2023-12-02 05:34:16 24 4
gpt4 key购买 nike

我想让我的应用程序看起来不错。我想在启动时添加启动画面。启动屏幕(3-5 秒)后,应用程序应启动 Activitygrade678。

这是启动屏幕的 xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ImageView
android:src="@drawable/final2"
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"/>

</LinearLayout>

这是splash.java

    import android.app.Activity; 
import android.content.Intent;
import android.os.Bundle;
public class splash extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

}
}

启动后我希望它移动到应用程序

Intent intent = new Intent (splash.this,Actvitygrade678.class);
startActivity(intent);

最佳答案

首先创建您想要的布局,然后在主启动 Activity 中运行一个线程,该线程显示给定时间的启动屏幕布局,然后启动 MainActivity电子enter link description here

public class Splash extends Activity {
private final int DISPLAY_LENGTH = 1000;

@Override
public void onCreate(Bundle saved) {
super.onCreate(saved);
setContentView(R.layout.splashscreen);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(Splash.this,MainActivity.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, DISPLAY_LENGTH);
}
}

关于java - 如何在 Android 应用程序上放置闪屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25172201/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com