<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#ff0000"/>
<size android:width="50dp"
android:height="50dp"/></shape>
<h3>布局xml文件中使用imageview控件
<h2>(2)繪制直線<h2>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke android:width="1dp" //線的粗度
android:color="#ff0000" //顏色
android:dashWidth="2dp" //虛線的線段長(zhǎng)度
android:dashGap="3dp"/> //虛線的間隔長(zhǎng)度
</shape>
<h2>(3)繪制矩形<h2>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="45" //漸變角度 45的整數(shù)倍
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>
<h2>(4)使用自定義字體<h2>
TextView textView = (TextView) findViewById(R.id.textView2);
Typeface tf = Typeface.createFromAsset(getAssets(),
"fonts/samplefont.ttf");
//讀取****字體****textView.setTypeface(tf);//設(shè)置****字體****
<h6>把****字體****格式文件.ttf,拷貝到assets目錄下更卒,讀取****字體****文件Typeface.createFromAsset,設(shè)置類型setTypeface<h6>