Android应用的资源

ShapeDrawableAndroid应用资源可分为两大类:

1.无法通过R清单类访问的原生资源,保存在assets(资产)目录下

2.课通过R资源清单类访问的资源,保存在res(资源)目录下


在Java里访问,语法格式为[<package_name>.].R.<resource_type>.<resource_name>

在xml里访问,语法格式为@[<package_name>:]<resource_type>/<resource_name>


现在开始慢慢学习

ShapeDrawable资源

摘抄文档

<?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" />
    <gradient
        android:angle="integer"
        android:centerX="integer"
        android:centerY="integer"
        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" />
    <stroke
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"
        android:dashGap="integer" />
</shape>

对标签做些解释:

根标签必须是<shape />,shape有4种,rectangle(矩形),oval(椭圆),line(水平直线),ring(圆环)

<corners />:仅用在矩形上,radius表示四个角半径,还有4个属性分别指每个角的半径

<gradient />:渐变色

angle:渐变方向,必须是45的倍数,0是左到右,90是下到上,默认0

(centerX,centerY):渐变中心坐标,float型,范围(0,1.0)

startColor:渐变开始的颜色

endColor:渐变结束的颜色

centerColor:渐变中心的颜色,介于startColor和endColor之间

type:渐变方式,linear(线性),radial(辐射),sweep(扫描)

radial需要gradientRadius这个参数

具体参看:使用  原理需要美学吧,而且三种方式的哪些参数代表什么并不是很清楚,自己慢慢试吧。

padding:注意这个不是对shape起作用,而是对view的内容,比如文字

stroke:边框,width边框宽度,color边框颜色,dashWidth框线长度(有间隔),dashGap框线间隔

solid:color表示向shape内部填充颜色,会覆盖之前的

来几篇好文章:

圆角和边框

ShapeDrawable

译文


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值