代码设置TextView、Button等控件圆角边框背景颜色
2015-09-28 09:36
656 查看
int strokeWidth = 5; // 3dp 边框宽度
int roundRadius = 15; // 8dp 圆角半径
int strokeColor = Color.parseColor("#2E3135");//边框颜色
int fillColor = Color.parseColor("#DFDFE0");//内部填充颜色
GradientDrawable gd = new GradientDrawable();//创建drawable
gd.setColor(fillColor);
gd.setCornerRadius(roundRadius);
gd.setStroke(strokeWidth, strokeColor);
setBackgroundDrawable(gd);但是如果想设置Gradient的渐变色该咋办呢?方法是改变GradientDrawable的创建方法:int
colors[] = { 0xff255779 , 0xff3e7492, 0xffa6c0cd };//分别为开始颜色,中间夜色,结束颜色
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);
int roundRadius = 15; // 8dp 圆角半径
int strokeColor = Color.parseColor("#2E3135");//边框颜色
int fillColor = Color.parseColor("#DFDFE0");//内部填充颜色
GradientDrawable gd = new GradientDrawable();//创建drawable
gd.setColor(fillColor);
gd.setCornerRadius(roundRadius);
gd.setStroke(strokeWidth, strokeColor);
setBackgroundDrawable(gd);但是如果想设置Gradient的渐变色该咋办呢?方法是改变GradientDrawable的创建方法:int
colors[] = { 0xff255779 , 0xff3e7492, 0xffa6c0cd };//分别为开始颜色,中间夜色,结束颜色
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);
相关文章推荐
- Android中的Shape和Selector的结合使用实例
- Android Selector和Shape的使用方法
- android之shape使用
- android:shape的使用
- Android shape属性介绍
- android 高颜值app开发第一步——颜色与渐变
- android shape 的属性
- WPF学习(一)绘制图形的三种方法及区别
- WPF学习(一)绘制图形的三种方法及区别
- 安卓控件增加自定义点击效果
- 给UIView加渐变色背景
- CSS3 Gradient 线性渐变/径向渐变
- Android 如何使用shape绘制只有一个圆角的矩形
- EXCEL数据根据XY坐标导入ArcGIS
- Android Shape详解
- Android开发之Shape自定义圆角按钮
- CSS3 Gradient
- Drawable资源之shape drawable
- android中shape的用法
- android shape的使用