Android 实现各种形状和颜色的按钮
Android 实现各种形状的按钮
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 设置固定填充色 -->
<solid android:color="#f00" /> //颜色可以自己设定
<size android:width="60dp" android:height="30dp"/>
</shape>
看一下效果:
形状2:
<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>
形状3:
<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>
形状4:
<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>
形状5:
<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>
形状6:
<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>
形状7:
<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>
形状8:
<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>
形状9:
<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>
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgfagjb
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01