Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.
I have added windowBackground to my style

<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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

In the onCreate method of your activity you have a line like this:

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading