hualuoshuijia
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke android:color="#d6d6d6"
        android:width="1dp"/>//设置边框的颜色和宽度

//设置边框的圆角 <corners android:topLeftRadius="5dp" android:topRightRadius="5dp" android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp"/>
<solid android:color="#f75830" ></solid>//设置边框的填充色
</shape>

 

1.动态改变边框的颜色:

spaceTV = (TextView)findViewById(R.id.space);//spaceTV需要改变边框的控件
GradientDrawable drawable = (GradientDrawable) spaceTV.getBackground();
drawable.setStroke(1, Color.parseColor("#ff0000"));//设置边框的宽度和颜色
如果使用自己定义的颜色请使用drawable.setColor(getResources().getColor(R.color.yellow_color));
设置填充色

drawable.setColor( Color.parseColor("#ff495b"));

事情该步骤的前提:
compile \'com.android.support:design:25.+\'
不然会有一堆的错误

分类:

技术点:

相关文章:

  • 2021-04-08
  • 2022-02-07
  • 2021-12-04
  • 2021-12-19
  • 2021-09-23
  • 2021-10-23
  • 2021-07-11
  • 2021-08-24
猜你喜欢
  • 2021-12-26
  • 2021-11-19
  • 2021-11-19
  • 2021-04-26
  • 2021-11-19
  • 2021-12-28
  • 2021-12-04
  • 2021-04-09
相关资源
相似解决方案