There is an Activity , in it a fragment, in this fragment there is a WebView in the whole fragment, and also a FrameLayout , in which the ProgressBar over the WebView .

In TheFragment.OnCreateView inflates the layout, then WebView is configured, WebView can also happen - work with the base there, then loadUrl is called loadUrl , and then the progressbar is hidden in WebViewClient.onPageFinished .

And where is the progress bar shown in front of all this? The fact of the matter is that it was originally VISIBLE . However, when opening a fragment, it takes about half a second before it appears. How can you speed up?

Does the fact that the WebView in the tree is located in front of the ProgressBar and its creation takes this time?

Do I onCreateView understand that onCreateView is called before any rendering, if so, is it possible to call it already in it so that the progress onCreateView will at least appear (albeit in a frozen state).

    1 answer 1

    Show progress to the method onCreate impossible. As a rule, you need to let the onCreate method work as quickly as possible with the removal of everything heavy into background threads. The plan is:

    1. We start the activation. All views except the progress bar are invisible.
    2. We give work on the onCreate method () in which processing of all heavy tasks in a background is started. We transfer there callback.
    3. The view is drawn and displays the progress.
    4. After some time, the callback information comes b displayed on the screen.
    5. Hide progress bar.

    In the case of WebView, you can hang the listener on it and show it only when the page loads.

    If we work with the base, then we pull out the data asynchronously, and not in the main thread.