新建shape文件,颜色需要自己定义

新建shape
shape属性:(默认矩形)
- line--线
- oval--椭圆
- rectangle--圆角矩形
shape有6个属性节点
- corners :圆角
- gradient :渐变
- padding :内容离边界距离
- size :大小
- solid :填充颜色
- stroke :描边
下面是常见常用shape直接copy代码,颜色根据自己需求设置整个文件当作background属性引用即可
一、
渐变色:
image.png
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
    <gradient
        android:startColor="@color/point_green"
        android:endColor="@color/actionsheet_blue"/>
    <size
        android:width="200dp"
        android:height="100dp"/>
</shape>
二、
圆角矩形框:
image.png
shape.xml
 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
        <corners
          android:radius="15dp"/>
        <stroke
          android:width="2dp"
          android:color="@color/point_green"/>
        <size
          android:width="200dp"
          android:height="100dp"/>
</shape>
三、
圆角矩形实心:
image.png
shape.xml
 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <corners
    android:radius="15dp"/>
  <solid
      android:color="@color/point_green"/>
  <size
    android:width="200dp"
    android:height="100dp"/>
</shape>
四、
圆角带边框实心:
image.png
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
  <corners
      android:radius="15dp"/>
  <stroke
    android:width="2dp"
    android:color="@color/color_green"/>
  <solid
    android:color="@color/login_button_bg_gray"/>
  <size
    android:width="200dp"
    android:height="100dp"/>
</shape>
五、
左圆角右直角:
image.png
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
  <corners
    android:topLeftRadius="15dp"
    android:bottomLeftRadius="15dp"/>
  <stroke
    android:width="2dp"
    android:color="@color/color_green"/>
  <solid
    android:color="@color/login_button_bg_gray"/>
  <size
    android:width="200dp"
    android:height="100dp"/>
</shape>
六、
圆框:
image.png
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
  <stroke
    android:width="2dp"
    android:color="@color/color_green"/>
  <solid
    android:color="@color/login_button_bg_gray"/>
  <size
    android:width="100dp"
    android:height="100dp"/>
</shape>
七、
虚线:
image.png
shape.xml
 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="line">
  <stroke
    android:width="1dp"
    android:dashWidth="3dp"
    android:dashGap="8dp"
    android:color="@color/point_green"/>
</shape>
八、
虚线框:
image.png
shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <stroke
    android:width="1dp"
    android:dashWidth="3dp"
    android:dashGap="8dp"
    android:color="@color/point_green"/>
  <size
    android:width="200dp"
    android:height="100dp"/>
</shape>







