Material-components-android: Add material LinearProgressBar widget

Created on 9 Jan 2019  路  6Comments  路  Source: material-components/material-components-android

duplicate enhancement new component

Most helpful comment

@dbrgn this is a KitKat progress bar. I don't think you want this in a material styled app these days.

All 6 comments

I think you can accomplish this already with a normal ProgressBar with the Horizontal style.

<ProgressBar
            android:id="@+id/progress_bar"
            style="@style/Widget.AppCompat.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:scaleY="4"
            android:indeterminate="true" />

@froriz5 Thank you, that's actually pretty close! Still, there is small padding on the top, but that's probably because of the arithmetic rounding, not sure (I exaggerated the height to make it visible). The discoverability of this hackish solution is quite low tho. The only reason scaleY="4" works is because the height of the bar is set to 16dp internally and the progress drawable is 1/4 of this height: <dimen name="progress_bar_height_material">4dp</dimen> (from SDK source code). So we scale it up, to fill the whole height. It's a pretty tall ask to require from people to know this stuff in order to make the widget compliant with the guidelines.
screenshot_20190117-005408__01

@Ghedeon I did something similar: https://github.com/gfroerli/app-android/commit/24c82340d3333bd451f5552b24132f0c73849a3d

index

         <ProgressBar
            android:id="@+id/loadingbar"
            style="@android:style/Widget.Holo.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="6dp"
            android:minHeight="6dp"
            android:maxHeight="6dp"
            android:scaleY="2"
            android:layout_margin="0dp"
            android:padding="0dp"
            android:indeterminate="true"
            android:visibility="invisible"/>

It's close to the guidelines, but still far from ideal.

I'm also looking forward to an implementation of #83.

@dbrgn this is a KitKat progress bar. I don't think you want this in a material styled app these days.

Yes, you're right @Ghedeon, the MaterialProgressBar library should not exist. However, I am using it in my app because I have to, and there is no other way to put a progress bar under the toolbar. This should be implemented here!

Duplicate of #83

Was this page helpful?
0 / 5 - 0 ratings