您的位置:首页 > 编程语言

代码中动态该变shape的颜色

2016-07-25 17:25 465 查看


How
to change shape color dynamically?、

http://stackoverflow.com/questions/7164630/how-to-change-shape-color-dynamically#

If you have an imageView like this:
<ImageView
android:id="@+id/color_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="@drawable/circle_color"/>


which give it a drawable shape as src, you can use this code to change shape's color:
ImageView iv = (ImageView)findViewById(R.id.color_button);
GradientDrawable bgShape = (GradientDrawable)iv.getDrawable();
bgShape.setColor(Color.BLACK);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: