1>.改变shape的颜色
(1)GradientDrawable view_ground = (GradientDrawable)view.getBackground(); //获取控件的背景色
(2)view_ground.setColor(Color.parseColor(text_background));//设置背景色
2>.代码生成shape
//创建Drawable对象
GradientDrawable drawable=new GradientDrawable();
//设置背景色
drawable.setColor(color);
//设置边框的宽度以及边框的颜色
drawable.setStroke(1,color);
//设置圆角的半径
drawable.setCornerRadius(r);
//设置shape形状
drawable.setShape();
//控件设置shape背景
view.setBackground(drawable);
最后
以上就是乐观河马最近收集整理的关于android 动态生成shape以及动态的改变shape颜色的全部内容,更多相关android内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复