Issue
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
Solution
What you can do is setting the content view to another Layout and when you know the pdf is loaded you can show the 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.
Answered By - Afonso Fonseca
Answer Checked By - Pedro (JavaFixing Volunteer)