首先,新建xml文件,resource type为drawble,root element为shape

一、自定义画线

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <stroke android:width="1dp"  //线的粗度
        android:color="#33ccff"  //颜色
        android:dashWidth="2dp"  //虚线的线段长度
        android:dashGap="5dp"/>  //虚线的间隔长度
</shape>


布局xml文件中可以使用textview控件,设置背景属性


二、自定义画圆

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <solid android:color="#33ccff"/>
    <size android:width="50dp"  //圆或椭圆
    android:height="50dp"/>
</shape>


布局xml文件中使用p_w_picpathview控件


三、自定义画矩形

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <gradient
        android:angle="45"   //渐变角度  45的整数倍
        android:centerColor="#00ff00"   //渐变颜色
        android:endColor="#0000ff"
        android:startColor="#ff0000" />
    <solid android:color="#33ccff" />   //纯色
    <size
        android:height="100dp"
        android:width="50dp" />
    <corners android:radius="10dp" />  //圆角
</shape>


四、使用自定义字体


把字体格式文件.ttf,拷贝到assets目录下,读取字体文件Typeface.createFromAsset,设置类型setTypeface


代码中使用字体如下:

TextView textView = (TextView) findViewById(R.id.textView2);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/samplefont.ttf");//读取字体
textView.setTypeface(tf);//设置字体