2013-12-11 62 views
0

我想設置我的ProgressBar的顏色獲取TextView的顏色。 我還沒有找到任何關於此的文檔。 這是我的TextView:tv.setBackgroundColor(m.color); ,這是我的進度:Android顏色ProgressBar通過textview

int pr = (int)(value); mProg = (ProgressBar)row.findViewById(R.id.progress_e); mProg.setMax(100); mProg.setProgress(pr);

哪能?

回答

0
tv.setBackgroundColor(m.color); 

mProg.getIndeterminateDrawable().setColorFilter(m.color, 
android.graphics.PorterDuff.Mode.MULTIPLY); 

如果你想獲取的TextView的顏色,簡單的方法來做到這一點。將其顏色設置爲它的標籤,檢索,分析它,並把它作爲進度的setColorFilter的參數。

//to set it: 
tv.setBackgroundColor(m.color); 
tv.setTag(m.color); 

//to retrieve it: 
int color=Integer.parseInt(tv.getTag().toString()); 
mProg.getIndeterminateDrawable().setColorFilter(color, 
      android.graphics.PorterDuff.Mode.MULTIPLY); 
+0

我用你的代碼做了它,從我的logcat中獲取顏色,但進度條仍然設置爲默認顏色。 – user2867831

+0

顏色的價值是什麼? – RominaV

+0

顏色示例值:-65463 – user2867831