【问题标题】:Showing logo 3 seconds before loading mainActivity [duplicate]在加载 mainActivity 前 3 秒显示徽标 [重复]
【发布时间】:2016-08-26 17:58:18
【问题描述】:

在启动我的 android 应用程序时,我想在主活动加载前 3 秒在自己的活动中显示一个徽标(一个自己的活动)。哪种方法最简单?

我搜索了这个论坛,我只能找到一个关于这个主题的答案,但不幸的是它对我没有用。

【问题讨论】:

    标签: android splash-screen


    【解决方案1】:

    我认为您指的是如何实现启动画面,

    创建一个新的空activity,在这个例子中我称之为Splash

    public class SplashScreen extends Activity {
    
        // Sets splash screen time in miliseconds
        private static int SPLASH_TIME = 3000;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash);
    
            new Handler().postDelayed(new Runnable() {
    
    
                @Override
                public void run() {
    
                    // run() method will be executed when 3 seconds have passed
    
                    //Time to start MainActivity
                    Intent intent = new Intent(Splash.this, MainActivity.class);
                    startActivity(intent );
    
                    finish();
                }
            }, SPLASH_TIME);
        }
    
    }
    

    确保您已在清单文件中将 Splash 活动设置为启动器活动:

     <activity
         android:name=".Splash"
         android:theme="@android:style/Theme.NoTitleBar">
           <intent-filter>
    
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
    
           </intent-filter>
    </activity>
    

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多