What's the meaning of android:progressBarStyle attribute in ProgressBar?

后端 未结 3 558
故里飘歌
故里飘歌 2020-12-23 16:25

I\'ve been looking through the documentation for ProgressBar class and found these attributes:

  • android:progressBarStyle
  • android:progressB
相关标签:
3条回答
  • 2020-12-23 17:08

    The four attributes that you mention can be applied to a ProgressBar's style like so:

    style="?android:attr/progressBarStyleHorizontal"
    

    The style constant android:progressBarStyleHorizontal is your typical incremental progress bar:

    alt text

    While the other three are varying sizes of the same circular progress bar:

    style="?android:attr/progressBarStyleSmall"
    

    alt text

    style="?android:attr/progressBarStyle"
    

    alt text

    style="?android:attr/progressBarStyleLarge"
    

    alt text

    Update:

    According to adamp's comments:

    These are attributes of the theme that point at themed styles you can use for progress indicators...They are not attributes for ProgressBar itself.

    0 讨论(0)
  • 2020-12-23 17:08

    The confusing part is that normally, you can define a default style for a widget (e.g. a button) like this:

    <item name="android:buttonStyle">@style/Widget.AppCompat.Button.Colored</item>
    

    All buttons will then by default have this style applied.

    One would think that the progressBarStyle attribute would do the same for ProgressBar if doing this:

    <item name="android:progressBarStyle">@style/Widget.AppCompat.ProgressBar</item>
    

    But that is not the case, since progressBarStyle belongs to the ActionBar styleable.

    0 讨论(0)
  • 2020-12-23 17:16

    In case if someone is looking for full block of code

    <ProgressBar
    android:id="@+id/ProgressBar2"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
    
    0 讨论(0)
提交回复
热议问题