上一篇 这里就不过多讲解 具体是这么设置的,这篇文章主要分享 各种形状和颜色的按钮。
形状1:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置固定填充色 -->
<solid android:color="#f00" /> //颜色可以自己设定
<size android:width="60dp" android:height="30dp"/>
</shape>
看一下效果:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="60dp" android:height="30dp"/>
<!-- 设置渐变填充色 -->
<gradient android:startColor="#00f" android:centerColor="#0f0" android:endColor="#f00"></gradient>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
<stroke
android:width="2dp"
android:color="#f00" >
</stroke>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
<stroke
android:width="2dp"
android:color="#f00"
android:dashWidth="5dp"
android:dashGap="5dp">
</stroke>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
<stroke
android:width="2dp"
android:color="#f00"
android:dashWidth="5dp"
android:dashGap="5dp"></stroke>
<corners android:radius="15dp"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置固定填充色 -->
<solid android:color="#f00" />
<size
android:width="60dp"
android:height="30dp"/>
<corners android:radius="10dp"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="60dp" android:height="30dp"/>
<!-- 设置渐变填充色 -->
<gradient
android:startColor="#f00"
android:centerColor="#0f0"
android:endColor="#00f"
android:gradientRadius="60"
android:type="radial"></gradient>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
<stroke android:width="2dp" android:color="#FFBB86FC" ></stroke>
<corners android:radius="15dp"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
>
<size android:width="60dp" android:height="30dp"/>
<!-- 设置渐变填充色 -->
<gradient android:startColor="#4169E1"
android:centerColor="#D2691E"
android:endColor="#87CEFA"
android:type="sweep">
</gradient>
</shape>
形状10:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边 -->
<stroke
android:width="2dp"
android:color="#f00"
android:dashWidth="5dp"
android:dashGap="5dp">
</stroke>
<corners
android:radius="15dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"/>
</shape>
形状11:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<!-- 设置固定填充色 -->
<solid android:color="#48D1CC" />
<size android:width="60dp" android:height="30dp"/>
</shape>
形状12:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="60dp" android:height="30dp"/>
<!-- 设置渐变色 -->
<gradient
android:startColor="#00f"
android:centerColor="#0f0"
android:endColor="#f00"></gradient>
</shape>
形状13:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边色 -->
<stroke
android:width="2dp"
android:color="#f00" >
</stroke>
</shape>
形状14:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="60dp" android:height="30dp"/>
<!-- 设置描边色 -->
<stroke
android:width="2dp"
android:color="#f00"
android:dashWidth="5dp"
android:dashGap="5dp">
</stroke>
</shape>
形状15:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="20dp"
android:shape="ring"
android:thickness="2dp"
android:useLevel="false" >
<!-- 设置固定填充色 -->
<solid android:color="#f00" />
<size
android:height="20dp" />
</shape>
形状16:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="20dp"
android:shape="ring"
android:thickness="2dp"
android:useLevel="false" >
<!-- 设置渐变填充色 -->
<gradient
android:startColor="#00f"
android:centerColor="#0f0"
android:endColor="#f00"/>
<size
android:height="44dp"/>
<stroke
android:width="2dp"
android:color="#f00"
android:dashWidth="5dp"
android:dashGap="5dp"/>
</shape>
形状17:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:dashGap="8px"
android:dashWidth="8px"
android:width="1dp"
android:color="#f00" />
<size android:height="30dip" />
</shape>
因篇幅问题不能全部显示,请点此查看更多更全内容