你怎么能动态更新搜索栏的颜色? [英] How can you dynamically update the color of a SeekBar?

查看:168
本文介绍了你怎么能动态更新搜索栏的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有进度条(特别是二级进步与<一个更新的颜色href="http://developer.android.com/reference/android/widget/ProgressBar.html#setSecondaryProgress%28int%29">setSecondaryProgress)动态地在运行时改变,当它穿过某一点。

I would like to have the color of the progress bar (specifically the secondary progress that is updated with setSecondaryProgress) to change dynamically at runtime when it crosses a certain point.

我已经能替代我自己绘制成在我活动的onCreate功能吧致电setProgressDrawable而代以资源我从默认的Andr​​oid版本的水平进度复制(SDK(改变颜色从黄色变为绿色) /platforms/android-2.1/data/res/drawable/progress_horizo​​ntal.xml)。然而,在运行时更新这个(是的,从通过AsyncTask的UI线程),使整个进度条除thumbtab去黑色或透明的。

I am already able to substitute my own drawable into the bar during my Activity's onCreate function (changing color from yellow to green) by calling setProgressDrawable and substituting a resource I've copied from the default Android version of a horizontal progress (SDK/platforms/android-2.1/data/res/drawable/progress_horizontal.xml). However, updating this at runtime (yes, from the UI thread via an AsyncTask) causes the entire progress bar except for the thumbtab to go black or transparent.

推荐答案

我想这是你在找什么

这可以通过为背景seak酒吧与进步创建自定义drwables被achived 见样品code这链接

This can be achived by creating custom drwables for background and progress of seak bar See this link for sample code.

请参阅下面的链接也 http://javatechig.com/android/android-seekbar-example/

Pls see the below links also http://javatechig.com/android/android-seekbar-example/

<一个href="http://stackoverflow.com/questions/9837843/change-the-color-of-a-seekbar-on-onprogresschanged">Change一个搜索栏对onProgressChanged

这篇关于你怎么能动态更新搜索栏的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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