侯剑凯 发表于 2012-12-19 23:16:23

Android layer-list shape corners

<div id="cnblogs_post_body">Android的图片资源应用非常广泛,它们可以很容易的被绘制到screen,同时设定图片资源的方式也有很多种,例如可以通过类似getDrawable(int)的API获取,也或或则可以通过在XML资源里设定,例如通过设定属性android:drawable 和 android:icon,来设定图片资源。同样我们也有很多种类型的图片资源,例如:Bitmap File,Nine-Patch File,Layer List,State List,Level List,Transition Drawable,Inset Drawable,Clip Drawable,Scale Drawable,Shape Drawable等。详细介绍请访问:Drawable Resources。
那么这章向大家介绍的是其中一种类型:Shape Drawable,以下是有关的一些基础知识的介绍:

This is a generic shape defined in XML.
file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a GradientDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:<div class="cnblogs_code"> 1 <?xml version="1.0" encoding="utf-8"?> 2 <shape 3   xmlns:android="http://schemas.android.com/apk/res/android" 4   android:shape=["rectangle" | "oval" | "line" | "ring"] > 5   <corners 6         android:radius="integer" 7         android:topLeftRadius="integer" 8         android:topRightRadius="integer" 9         android:bottomLeftRadius="integer"10         android:bottomRightRadius="integer" />11   <gradient12         android:angle="integer"13         android:centerX="integer"14         android:centerY="integer"15         android:centerColor="integer"16         android:endColor="color"17         android:gradientRadius="integer"18         android:startColor="color"19         android:type=["linear" | "radial" | "sweep"]20         android:useLevel=["true" | "false"] />21   <padding22         android:left="integer"23         android:top="integer"24         android:right="integer"25         android:bottom="integer" />26   <size27         android:width="integer"28         android:height="integer" />29   <solid30         android:color="color" />31   <stroke32         android:width="integer"33         android:color="color"34         android:dashWidth="integer"35         android:dashGap="integer" />36 </shape>
页: [1]
查看完整版本: Android layer-list shape corners