Android 实现各种形状和颜色的按钮
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 实现各种形状和颜色的按钮相关推荐
- android 悬浮按钮 功能实现,怎么在Android中利用FloatingActionButton实现一个悬浮按钮效果...
怎么在Android中利用FloatingActionButton实现一个悬浮按钮效果 发布时间:2020-12-02 17:41:30 来源:亿速云 阅读:238 作者:Leah 今天就跟大家聊聊有 ...
- Android 遥控器按键 布局,Android 类遥控器圆形控件 扇形按钮 带中间按钮
Android 类遥控器圆形控件 扇形按钮 带中间按钮 前言 效果图 使用方法 添加依赖 在布局中使用 参数设定 设定是否有中间按钮 设定正常情况下的中间按钮的背景颜色 设定中间按钮的圆圈描边颜色 设 ...
- Android中设置TextView的颜色setTextColor
tv.setTextColor(Color.parseColor("#FFFFFF")); tv.setTextColor(Color.WHITE); tv.setTextColo ...
- R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的形状、颜色)实战
R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的形状.颜色)实战 目录 R语言使用ggplot2包使用geom_boxplot函数绘制基础分组箱图(设置异常值的 ...
- android 自定义背景园,Android 自定义ProgressBar 进度条颜色和背景颜色
Android 自定义ProgressBar 进度条颜色和背景颜色 首先,在drawable目录下新建文件 personal_center_level_progress_bg.xmlandroid a ...
- android AppCompatEditText 自定义下划线颜色
今天,就讲讲 AppCompatEditText设置下划线颜色的知识. 如下图所示: style中添加 </pre><pre name="code" cla ...
- Android动态改变TextView字体颜色
Android动态改变TextView字体颜色 分类: Android 2012-06-04 21:56 141人阅读 评论(0) 收藏 举报 androidcolorslayout 必须在在res/ ...
- Android Studio更改标题栏的颜色
Android Studio更改标题栏的颜色 第一步,在value的colors.xml文件夹中添加两个颜色.如下: #FFFFFF #000000 1 2 第二步,在value的style.xml文 ...
- 基于Android的rgb七彩环颜色采集器
代码地址如下: http://www.demodashi.com/demo/11892.html 一.前言. 在大学期间,看到这个rgb灯,蛮好奇的,这么漂亮的颜色采集,并且可以同步到设备rbg灯颜色 ...
最新文章
- linux添加审计账户_眼镜蛇W眼镜蛇白盒品白源代码审计工具 白帽子版
- java desktop和synth_java synth实例
- excel多个工作表求和案例
- 厉害了,我的清华大学,各系横幅让网友看花眼,尤其是第3条
- Python与Java-你首选哪个?
- android view设置按钮颜色_Android 酷炫自定义 View:高仿 QQ 窗帘菜单
- Linux下Apache与Tomcat整合调试
- mysql 插入多行_MySQL使用INSERT插入多条记录
- 计算机保研夏令营英语面试,保研经验 | 夏令营面试那些事儿(内含视频)
- 视频应用在区块链上的应用
- Deep Learning(深度学习)学习笔记
- 增值税下调对财务软件的影响
- 深度linux怎样设置显卡,在Deepin系统中安装英伟达NVIDIA显卡驱动的方法
- MACD、KDJ、DMA等常用技术指标的python实现
- 2013-2-22 ACM-第三次月赛 1001 铺地毯
- 转区系统开放艾欧尼亚转入服务器,【英雄联盟】转区系统开放艾欧尼亚转入服务...
- 【大学】我的大学四年
- solaris磁带机 tar 备份
- java装逼的话_程序员装逼指南(语言篇)
- PostgreSQL的ON CONFLICT