简体   繁体   English

如何在启动画面中添加进度条

[英]How to add Progress Bar in Splash Screen

I want to add a Progress Bar to my splash screen but my splash screen is not an Activity.我想在启动画面中添加进度条,但启动画面不是 Activity。
I have added windowBackground to my style我已将windowBackground加到我的样式中

<style name="Theme" parent="Theme.MaterialComponents.Light.NoActionBar">

    <item name="android:windowBackground">@drawable/splash_image</item>
    <item name="android:statusBarColor">@color/white</item>

</style>

It is a PDF Viewer App which takes more time to load since it has to check for all the PDFs on the device这是一个 PDF 查看器应用程序,需要更多时间来加载,因为它必须检查设备上的所有 PDF

What you can do is setting the content view to another Layout and when you know the pdf is loaded you can show tha proper view or launch a new Activity.您可以做的是将内容视图设置为另一个布局,当您知道 pdf 已加载时,您可以显示正确的视图或启动新的活动。

In the onCreate method of your activity you have a line like this:在您的活动的 onCreate 方法中,您有这样一行:

setContentView(R.layout.activity_main)

You could instead replace that with your new layout that you created that has a progress bar.您可以将其替换为您创建的具有进度条的新布局。

setContentView(R.layout.splash_screen)

And when you finished loading the pdf you can call the setContentView of your activity again and it will show everything.当您完成加载 pdf 后,您可以再次调用活动的 setContentView,它将显示所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM