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

标签 java android splash-screen

我想让我的应用程序看起来不错。我想在启动时添加启动画面。 启动屏幕(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/

相关文章:

ios - 使用 iPad 模拟器 6.1 删除 xcode 4.6.3 中的启动画面

Java正则表达式查找其中没有句点的数字

java - log4j级别跟踪和调试没有显示任何日志

java - 根据文档列表查询 FireStore

android - Google Now 家庭定位

android - 我应该在 Android 中为启动画面保留什么图像大小?

java - 客户端必须具有 ACCESS_FINE_LOCATION 权限才能请求 PRIORITY_HIGH_ACCURACY 位置运行时错误

java - 当手机没有任何互联网时无法从 url 获取图标,或者是否可以保存在内部存储然后从那里读取

android - 返回的 AlertDialog 上的 .show() 抛出致命异常

android - 有没有办法改变 Android 12 中启动画面图标的形状?