如何以编程方式更改进度条颜色

时间:2014-03-26 12:49:27

标签: android

我正在使用此示例代码来显示信号信息http://code.google.com/p/krvarma-android-samples/source/browse/trunk/PhoneStateSample/src/com/varma/samples/phonestatesample/PhoneStateSample.java,其中显示下面进度条中的信号强度是我的代码,我从该示例类中获取了哪一部分我的问题是我将如何更改创建程序化的进度条的颜色?

                private void setSignalLevel(int id,int infoid,int level){
            int progress = (int) ((((float)level)/31.0) * 100);
            String signalLevelString = getSignalLevelString(progress);

            ((ProgressBar)findViewById(id)).setProgress(progress);

            ((TextView)findViewById(infoid)).setText(signalLevelString);

            Log.i("signalLevel ","" + progress);
    }

1 个答案:

答案 0 :(得分:0)

试试这个:

yourProgressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.MULTIPLY);

在你的情况下:

((ProgressBar)findViewById(id)).getProgressDrawable().setColorFilter(Color.RED, Mode.MULTIPLY);
相关问题