安卓splash页面瞬间响应_APP启动闪白屏问题

自定义style

<style name="AppSplash" parent="AppTheme">
        <item name="android:windowBackground">@mipmap/doutu</item>
</style>

然后在AndroidManifest.xml中配置如下:s

<activity android:name=".SplashActivity" android:theme="@style/AppSplash">
   <intent-filter>
         <action android:name="android.intent.action.MAIN" />

         <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
 </activity>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安卓中的Splash页面是应用程序启动时显示的加载界面,通常用于展示应用程序的logo、名称或其他加载信息。以下是一个简单的Splash页面的示例代码: 1. 创建一个新的Activity作为Splash页面,命名为SplashActivity。 ```java public class SplashActivity extends AppCompatActivity { private static final int SPLASH_TIMEOUT = 2000; // 设置延时时间为2秒 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); new Handler().postDelayed(new Runnable() { @Override public void run() { // 延时操作完成后跳转到主界面 Intent intent = new Intent(SplashActivity.this, MainActivity.class); startActivity(intent); finish(); } }, SPLASH_TIMEOUT); } } ``` 2. 创建activity_splash.xml布局文件,并在其中设计Splash页面的界面。例如,可以添加一个ImageView来显示应用程序的logo: ```xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white"> <ImageView android:layout_width="120dp" android:layout_height="120dp" android:src="@drawable/app_logo" android:layout_centerInParent="true" /> </RelativeLayout> ``` 在上述示例中,我们创建了一个SplashActivity,并在其中设置了一个延时操作。在延时时间结束后,我们使用Intent跳转到应用程序的主界面MainActivity,并结束SplashActivity。 您可以根据自己的需求来设计和定制Splash页面,例如添加动画效果、加载进度条等。记得在AndroidManifest.xml文件中将SplashActivity设置为应用程序的启动Activity。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值