1. 首先上一个效果图
12.上代码
GradientDrawable drawable =newGradientDrawable();
drawable.setCornerRadius(20);
drawable.setColor(Color.parseColor("#f00000"));
drawable.setStroke(5,Color.parseColor("#f0f000"));
tv_123.setBackgroundDrawable(drawable);
3. 代码添加选择器
StateListDrawableselectDrawable =newStateListDrawable();
selectDrawable.addState(new int[]{-android.R.attr.state_pressed},drawable1);
selectDrawable.addState(new int[]{android.R.attr.state_pressed},drawable);
网友评论