2015-12-13 238 views
1

我正在使用CircleImageView来制作圆形图像,但我想覆盖此图片的顶部。 Sicne设置CircleImageView backgroundColor摆脱圆圈(将其填充为正方形)我有一个常规图像视图,并将其放在CircleImageView之上,并将常规图像视图.setImageDrawable设置为我想要的图片。但我需要在编程上将CircleImageView的src设置为我目前拥有的和int的颜色。所以我想知道如何将CircleImageView src设置为一种颜色?以编程方式设置ImageView SRC Android

我试图backgroundImage.setBackgroundResource(colorAsInt);

,但是这给了错误:android.content.res.Resources$NotFoundException: Resource ID #0xff7f0106

感谢

+0

try backgroundImage.setBackgroundColor(Color.rgb(100,100,100)); – JRowan

+0

@JRowan我无法设置backgroundColor,因为它从'CircleImageView'中移除了圆,只是填满了整个背景 – spenf10

+1

尝试'backgroundImageImageView.setImageDrawable(new ColorDrawable(colorAsInt));',不知道它是否可以工作;我没有使用过这个库。 –

回答

2

由于设置背景颜色击败查看的预期功能,它似乎是唯一的选择是设置源图像。使用所需颜色的ColorDrawable应该可以工作。

backgroundImageImageView.setImageDrawable(new ColorDrawable(colorAsInt)); 
相关问题