Android Shape详解

定义在 XML 中的几何形状。

 

File Location

    res/drawable/filename.xml

    文件名将被当作资源 ID 使用。

Complied Resource Datatype

    指向 ShapeDrawable 的资源指针。

Resource Reference

    R.drawable.filename Java

    @[package:]drawable/filename XML

 

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape=["rectangle" | "oval" | "line" | "ring"] > 
    <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:usesLevel=["true" | "false"] /> 
    <solid 
        android:color="color" /> 
    <stroke 
        android:width="integer" 
        android:color="color" 
        android:dashWidth="integer" 
        android:dashGap="integer" /> 
    <padding 
        android:left="integer" 
        android:top="integer" 
        android:right="integer" 
        android:bottom="integer" /> 
    <corners 
        android:radius="integer" 
        android:topLeftRadius="integer" 
        android:topRightRadius="integer" 
        android:bottomLeftRadius="integer" 
        android:bottomRightRadius="integer" /> 
</shape>

你可能感兴趣的:(xml,android)