Android 实现各种形状的按钮

上一篇 设置透明按钮和自定义背景 这里就不过多讲解 具体是这么设置的,这篇文章主要分享 各种形状和颜色的按钮。
形状1:

<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"/>
<!-- 设置描边 --><strokeandroid: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"/><!-- 设置描边色 --><strokeandroid: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" /><sizeandroid: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"/><sizeandroid: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" ><strokeandroid:dashGap="8px"android:dashWidth="8px"android:width="1dp"android:color="#f00" /><size android:height="30dip" />
</shape>

Android 实现各种形状和颜色的按钮相关推荐

  1. android 悬浮按钮 功能实现,怎么在Android中利用FloatingActionButton实现一个悬浮按钮效果...

    怎么在Android中利用FloatingActionButton实现一个悬浮按钮效果 发布时间:2020-12-02 17:41:30 来源:亿速云 阅读:238 作者:Leah 今天就跟大家聊聊有 ...

  2. Android 遥控器按键 布局,Android 类遥控器圆形控件 扇形按钮 带中间按钮

    Android 类遥控器圆形控件 扇形按钮 带中间按钮 前言 效果图 使用方法 添加依赖 在布局中使用 参数设定 设定是否有中间按钮 设定正常情况下的中间按钮的背景颜色 设定中间按钮的圆圈描边颜色 设 ...

  3. Android中设置TextView的颜色setTextColor

    tv.setTextColor(Color.parseColor("#FFFFFF")); tv.setTextColor(Color.WHITE); tv.setTextColo ...

  4. R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的形状、颜色)实战

    R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的形状.颜色)实战 目录 R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的 ...

  5. android 自定义背景园,Android 自定义ProgressBar 进度条颜色和背景颜色

    Android 自定义ProgressBar 进度条颜色和背景颜色 首先,在drawable目录下新建文件 personal_center_level_progress_bg.xmlandroid a ...

  6. android AppCompatEditText 自定义下划线颜色

    今天,就讲讲  AppCompatEditText设置下划线颜色的知识. 如下图所示: style中添加 </pre><pre name="code" cla ...

  7. Android动态改变TextView字体颜色

    Android动态改变TextView字体颜色 分类: Android 2012-06-04 21:56 141人阅读 评论(0) 收藏 举报 androidcolorslayout 必须在在res/ ...

  8. Android Studio更改标题栏的颜色

    Android Studio更改标题栏的颜色 第一步,在value的colors.xml文件夹中添加两个颜色.如下: #FFFFFF #000000 1 2 第二步,在value的style.xml文 ...

  9. 基于Android的rgb七彩环颜色采集器

    代码地址如下: http://www.demodashi.com/demo/11892.html 一.前言. 在大学期间,看到这个rgb灯,蛮好奇的,这么漂亮的颜色采集,并且可以同步到设备rbg灯颜色 ...

最新文章

  1. linux添加审计账户_眼镜蛇W眼镜蛇白盒品白源代码审计工具 白帽子版
  2. java desktop和synth_java synth实例
  3. excel多个工作表求和案例
  4. 厉害了,我的清华大学,各系横幅让网友看花眼,尤其是第3条
  5. Python与Java-你首选哪个?
  6. android view设置按钮颜色_Android 酷炫自定义 View:高仿 QQ 窗帘菜单
  7. Linux下Apache与Tomcat整合调试
  8. mysql 插入多行_MySQL使用INSERT插入多条记录
  9. 计算机保研夏令营英语面试,保研经验 | 夏令营面试那些事儿(内含视频)
  10. 视频应用在区块链上的应用
  11. Deep Learning(深度学习)学习笔记
  12. 增值税下调对财务软件的影响
  13. 深度linux怎样设置显卡,在Deepin系统中安装英伟达NVIDIA显卡驱动的方法
  14. MACD、KDJ、DMA等常用技术指标的python实现
  15. 2013-2-22 ACM-第三次月赛 1001 铺地毯
  16. 转区系统开放艾欧尼亚转入服务器,【英雄联盟】转区系统开放艾欧尼亚转入服务...
  17. 【大学】我的大学四年
  18. solaris磁带机 tar 备份
  19. java装逼的话_程序员装逼指南(语言篇)
  20. PostgreSQL的ON CONFLICT

热门文章

  1. 360路由器v2刷第三方固件_品胜云路由器Breed刷入详细教程,技巧和注意事项,功能大增...
  2. 微信公众号网页授权代码优化过程(一)
  3. 【微信小程序云开发】笔记
  4. 2016年网页设计的5个风向标
  5. 人工智能、机器学习与深度学习
  6. 图像清晰度评价(C#)
  7. 攒机笔记八:笔记本选购(上)
  8. frp+nginx+xposed搭建xp模块集群
  9. 流量封顶时代,容联七陌智能客服构筑企业“第二增长曲线”
  10. 虚拟机vm添加vmdk