The accepted answer should suffice in most cases, but if you'd rather not deal with the padding values, you can wrap ProgressIndicator
and Toolbar
, so that ProgressIndicator
sits on top of Toolbar
.
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.MyApp.AppBarOverlay">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/Theme.MyApp.PopupOverlay" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:indeterminate="true"
app:hideAnimationBehavior="inward"
app:indicatorColor="@color/colorSecondary"
app:showAnimationBehavior="outward" />
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
The difference is, if ProgressIndicator
is drawn on top of Toolbar
, then the height of AppBarLayout
stays same.
[With FrameLayout] [Without FrameLayout]
+-------------------+ ^ +-------------------+ ^
| | | | | |
| | | | | |
| | AppBarLayout | | |
+-------------------+ | | | AppBarLayout
| ProgressIndicator | | | | |
+-------------------+ V +-------------------+ |
| | | ProgressIndicator | |
| | +-------------------+ v
| | | |
. . . .
. . . .