Android资源类型 --> 形状可绘制图像shape

时间:2021-05-24 05:05:59   收藏:0   阅读:0

Android资源类型 ----> 形状可绘制图像shape

  1. 语法
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape=["rectangle" | "oval" | "line" | "ring"] >
    //为当前形状产生圆角
    <corners
        android:radius="integer"
        android:topLeftRadius="integer"
        android:topRightRadius="integer"
        android:bottomLeftRadius="integer"
        android:bottomRightRadius="integer" />
    //图像的渐变色,angle:图像旋转的角度(必须为45的倍数)
    <gradient
        android:angle="integer"
        android:centerX="float"
        android:centerY="float"
        android:centerColor="integer"
        android:endColor="color"
        android:gradientRadius="integer"
        android:startColor="color"
        android:type=["linear" | "radial" | "sweep"]
        android:useLevel=["true" | "false"] />
    <padding
        android:left="integer"
        android:top="integer"
        android:right="integer"
        android:bottom="integer" />
    //图像的大小
    <size
        android:width="integer"
        android:height="integer" />
    //图像的背景色
    <solid
        android:color="color" />
    //边框:width:边框的宽度
    <stroke
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"
        android:dashGap="integer" />
</shape>

实例 -- > 画一个圆

		<shape>
            <!--为形状产生圆角。仅当形状为矩形时适用。 -->
            <corners android:radius="30dp"
            />
            <!--用于填充图像的背景色。 -->
            <solid android:color="@color/white"/>
            <!--绘制图像的大小-->
            <size android:height="30dp"
                  android:width="30dp"/>
        </shape>
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!