如何更改不确定的 ProgressBar 的颜色? [英] How to change the color of an indefinite ProgressBar?

查看:22
本文介绍了如何更改不确定的 ProgressBar 的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下样式的进度条:style="?android:attr/android:progressBarStyleSmall"

I have a progressbar with the following style: style="?android:attr/android:progressBarStyleSmall"

遗憾的是,该条几乎是白色的,在我的情况下显示在白色背景上.因此,进度条几乎不可见.

Sadly the bar is nearly white and in my case displayed on a white background. The progressbar is nearly invisible because of that.

如何更改进度条的颜色?深灰色会很棒.

How can I change the color of the progressbar? A darker grey would be great.

推荐答案

栏是那种颜色的原因是你选择的样式.这是一个固定的样式,使用系统主题来生成 UI 元素.

The reason why the bar is of that color is because of the style you have selected. That is a fixed style and uses the system themes for the generation of UI elements.

此处.此progressBarStyleSmall 属性使用定义的样式 这里.

Look at the source code from here. This progressBarStyleSmall attribute uses the styles defined here.

<style name="Widget.ProgressBar.Small">
    <item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item>
    <item name="android:minWidth">16dip</item>
    <item name="android:maxWidth">16dip</item>
    <item name="android:minHeight">16dip</item>
    <item name="android:maxHeight">16dip</item>
</style>

只需按照 android 源代码中的示例创建自定义样式.您需要将 android:indeterminateDrawable 替换为您想要的.

Just create a custom style following the example from the android source code. You would need to replace the android:indeterminateDrawable to what you want.

这篇关于如何更改不确定的 ProgressBar 的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆