如何修改所有ProgressBar?

时间:2022-09-03 23:52:56

I'm able to modify the height, width, and outer color of a ProgessBar widget. But that doesn't seem to affect the inner part of the bar. The red line that progresses. Is there a way to modify that? Or do I need to create a custom widget for that?

我可以修改ProgessBar小部件的高度,宽度和外部颜色。但这似乎并没有影响到酒吧的内部。进展的红线。有没有办法修改它?或者我需要为此创建自定义小部件吗?

Thank you

如何修改所有ProgressBar?

2 个解决方案

#1


0  

You can use android:indeterminateTint="@color/green" in your xml.

您可以在xml中使用android:indeterminateTint =“@ color / green”。

You can also try setIndeterminateDrawable(drawable) or setIndeterminateTintList() (I didn't check this solution)

你也可以尝试setIndeterminateDrawable(drawable)或setIndeterminateTintList()(我没有检查这个解决方案)

#2


0  

You can increase the height of the progress indicator, it can be achieved by adding following parameter in your layout.xml for ProgressBar:

您可以通过在layout.xml中为ProgressBar添加以下参数来增加进度指示器的高度:

android:scaleY="5"

<ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleY="5"
         />

If you want to reduce the padding around the indicator, then modify layout_height attribute as follows:

如果要减少指示符周围的填充,请按如下方式修改layout_height属性:

 <ProgressBar
            android:id="@+id/progressBar"
            style="@style/Widget.AppCompat.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="5dp" 
             />

You can use following on version older than Lollipop to change the indicator's color:

您可以在Lollipop之前的版本上使用以下内容来更改指标的颜色:

progressBar.getProgressDrawable().setColorFilter(
    Color.RED, android.graphics.PorterDuff.Mode.SRC_IN);

For Lollipop and above, use following:

对于Lollipop及以上版本,请使用以下内容:

progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));

You can refer to this SO for progressBar color

您可以参考此SO获取progressBar颜色

#1


0  

You can use android:indeterminateTint="@color/green" in your xml.

您可以在xml中使用android:indeterminateTint =“@ color / green”。

You can also try setIndeterminateDrawable(drawable) or setIndeterminateTintList() (I didn't check this solution)

你也可以尝试setIndeterminateDrawable(drawable)或setIndeterminateTintList()(我没有检查这个解决方案)

#2


0  

You can increase the height of the progress indicator, it can be achieved by adding following parameter in your layout.xml for ProgressBar:

您可以通过在layout.xml中为ProgressBar添加以下参数来增加进度指示器的高度:

android:scaleY="5"

<ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleY="5"
         />

If you want to reduce the padding around the indicator, then modify layout_height attribute as follows:

如果要减少指示符周围的填充,请按如下方式修改layout_height属性:

 <ProgressBar
            android:id="@+id/progressBar"
            style="@style/Widget.AppCompat.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="5dp" 
             />

You can use following on version older than Lollipop to change the indicator's color:

您可以在Lollipop之前的版本上使用以下内容来更改指标的颜色:

progressBar.getProgressDrawable().setColorFilter(
    Color.RED, android.graphics.PorterDuff.Mode.SRC_IN);

For Lollipop and above, use following:

对于Lollipop及以上版本,请使用以下内容:

progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));

You can refer to this SO for progressBar color

您可以参考此SO获取progressBar颜色