I would like to show progress bar when android webview is loading and I used Activity.setProgess(int).
Android documentation says setProgress(int progress) was deprecated in API level 24. No longer supported starting in API 21.
So, what should I use instead to show progress when webview is loading?
Implement toolbar with progress bar or spinner.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_actionbar"
style="@style/HeaderBar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:visibility="visible"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ActionBarPopupThemeOverlay"
app:theme="@style/ActionBarThemeOverlay"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="right"
android:divider="?android:dividerVertical"
android:dividerPadding="8dp"
android:orientation="horizontal"
android:showDividers="beginning|middle">
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:id="@+id/toolbarProgressBar"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
Then find it in your view and update.
ProgressBar progressBar = (ProgressBar)findViewById(R.id.toolbarProgressBar);
progressBar.setIndeterminate(false);
progressBar.setProgress(x);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With