shape颜色渐变、圆角、半圆角、边框、填充
2017-08-06 15:33
316 查看
效果图:
1、shape:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--圆角-->
<corners
android:radius="5dp"
android:topLeftRadius="30dp"
android:bottomRightRadius="30dp"/>
<!--填充颜色-->
<solid android:color="#000"/>
<!--边框-->
<stroke
android:color="#808080"
android:width="2dp"/>
<!--渐变-->
<gradient
android:startColor="#f52"
android:centerColor="#f92"
android:endColor="#fe2"
android:angle="180"/>
</shape>
渐变的颜色把填充的颜色顶了,所以是可以去掉solid的
2、关于gradient的angle参数:
0 是从左到右
90是从下到上
180是从右到左
270是从上到下
360==0
3、还有一个type参数:
linear 线性渐变(默认)
radial 环形渐变
sweep 扇形渐变
渐变一般给个开始颜色和结束颜色,然后指定一下方向就行了
4、两边半圆角:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="999dp"/>
<stroke
android:width="1dp"
android:color="@color/colorPrimary"/>
<padding
android:bottom="10dp"
android:left="20dp"
android:right="20dp"
android:top="10dp"/>
</shape>
1、shape:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--圆角-->
<corners
android:radius="5dp"
android:topLeftRadius="30dp"
android:bottomRightRadius="30dp"/>
<!--填充颜色-->
<solid android:color="#000"/>
<!--边框-->
<stroke
android:color="#808080"
android:width="2dp"/>
<!--渐变-->
<gradient
android:startColor="#f52"
android:centerColor="#f92"
android:endColor="#fe2"
android:angle="180"/>
</shape>
渐变的颜色把填充的颜色顶了,所以是可以去掉solid的
2、关于gradient的angle参数:
0 是从左到右
90是从下到上
180是从右到左
270是从上到下
360==0
3、还有一个type参数:
linear 线性渐变(默认)
radial 环形渐变
sweep 扇形渐变
渐变一般给个开始颜色和结束颜色,然后指定一下方向就行了
4、两边半圆角:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="999dp"/>
<stroke
android:width="1dp"
android:color="@color/colorPrimary"/>
<padding
android:bottom="10dp"
android:left="20dp"
android:right="20dp"
android:top="10dp"/>
</shape>
相关文章推荐
- android自定义button边框,颜色渐变,圆角button快速生成
- android shape设置渐变、圆角、边框线
- 使用Drawble文件实现圆角,填充颜色,边框等属性的设置(Android)
- Android中用shape做渐变,边框,圆角等效果
- HTML5+CSS3-第二节(浏览器前缀、css新特征、文本溢出、新的颜色设定、透明设定、文本填充色、文本边框色、圆角)
- CSS3--多列布局、边框颜色、圆角、渐变效果、阴影反射
- xib中设置圆角,边框宽度,边框颜色等
- android给View设置边框 填充颜色 弧度
- Android:res之shape制作圆角、虚线、渐变
- android:shape的使用 -实心,渐变,描边,圆角
- 设置视图圆角,边框宽度/颜色
- shape画圆角矩形,渐变
- 图片圆角加阴影 + 按钮的渐变颜色
- CorelDRAW如何设置填充颜色和边框颜色
- anroid边框阴影-圆角阴影-渐变阴影
- 【控件扩展】带圆角、边框、渐变的panel
- Android:res之shape制作圆角、虚线、渐变
- Android学习——Button填充颜色及实现圆角
- UIButton 设置圆角 边框颜色 点击回调方法
- Android Style --圆角、填充、复用(shape、selector)