android WebView ProgressBar
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"/> <ProgressBar android:id="@+id/progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true" android:indeterminateTint="@color/orange"/> </RelativeLayout>
Для своей картинки вместо стандартного ProgressBar:
<ProgressBar android:id="@+id/progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true" android:indeterminateDrawable="@drawable/progress"/>
progress.xml
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/progress_icon" android:pivotX="50%" android:pivotY="50%"/>
MainActivity.java
public class MainActivity extends AppCompatActivity { private WebView webView; private ProgressBar spinner; String ShowOrHideWebViewInitialUse = "show"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView = findViewById(R.id.webView); spinner = findViewById(R.id.progress); webView.setWebViewClient(new CustomWebViewClient()); } private class CustomWebViewClient extends WebViewClient{ @Override public void onPageStarted(WebView view, String url, Bitmap favicon){ spinner.setVisibility(View.VISIBLE); if(ShowOrHideWebViewInitialUse.equals("show")){ view.setVisibility(View.INVISIBLE); } } @Override public void onPageFinished(WebView view, String url){ ShowOrHideWebViewInitialUse = "hide"; spinner.setVisibility(View.GONE); view.setVisibility(View.VISIBLE); super.onPageFinished(view, url); } } }