【发布时间】:2014-10-26 20:54:10
【问题描述】:
我想做以下事情:
- 我有一个
LinearLayout和几个ImageViews,它们的 xml 中定义了背景颜色。 - 我有一个
SeekBar。 - 通过移动
Seekbar我应该更改Imageviews背景的颜色。
我想保存默认的背景颜色但是找不到getbackgroundcolor方法,只有setbackground方法。
稍后我想在Seekbar 进行时更改颜色。
我现在有这样的东西:
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
int test = seekBar.getProgress();
//textView.setText("Valami" + test);
switch (test) {
case 0:
imageView0.setBackgroundColor(Color.RED);
imageView1.setBackground(Color.YELLOW);
break;
case 1:
imageView0.setBackgroundColor(Color.BLACK);
imageView1.setBackgroundColor(Color.BLACK);
break;
case 2:
imageView0.setBackgroundColor(Color.WHITE);
imageView1.setBackgroundColor(Color.YELLOW);
break;
}
我认为这不是正确的方法,我想通过获取实际的SeekBar 进度值来更改它们的颜色。例如,根据进度值对原始颜色代码添加一些值。
这是我的想法,但我不知道如何实现。
感谢您的帮助!
【问题讨论】:
-
在此处查看我的评论以获取相关解决方案:stackoverflow.com/questions/26564080/…
-
您好,谢谢,我会检查您提到的相关解决方案!
标签: android colors imageview seekbar