android shape设置渐变、圆角、边框线

来源:互联网 发布:java文件上传到服务器 编辑:程序博客网 时间:2024/05/29 19:26

1、渐变实体背景+圆角:

应用场景:按钮

这里写图片描述

<shape>            <gradient                android:endColor="@color/theme_24A7F2"                android:startColor="@color/theme_1AC6FF"                android:type="linear" />            <corners                android:bottomLeftRadius="100dp"                android:bottomRightRadius="100dp"                android:topLeftRadius="100dp"                android:topRightRadius="100dp" />        </shape>

2、不带渐变的实体弧角shape

应用场景:弹窗,对话框

这里写图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android"><corners    android:topLeftRadius="12dp" <!-- 左上角 -->    android:topRightRadius="12dp" <!-- 右上角 -->     android:bottomLeftRadius="12dp" <!-- 左下角 -->     android:bottomRightRadius="12dp"/> <!-- 右下角 -->     <solid        android:color="#24A7F2"/></shape>

3、带边框的圆角shape

应用场景:按钮

这里写图片描述

<shape xmlns:android="http://schemas.android.com/apk/res/android">    <solid android:color="#00000000" /><!-- 背景填充颜色 -->    <stroke        android:width="2dp"        android:color="#FF5252" /><!-- 描边,边框宽度、颜色 -->    <corners android:radius="100dp" /><!-- 边角圆弧的半径 --></shape>