1、在/res/drawable/目录下定义xml文件
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#ff0000"/>
<stroke android:width="3dp" color="00ff00"/>
<corners android:radius="13dp"/>
<padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp"/>
</shape>
2、在.java文件中使用自定义的色图资源
Resources res = this.getResources();
TextView t5 = (TextView)findViewById(R.id.t5);
t5.setBackgroundDrawable(res.getDrawable(R.drawable.shape));
3、运行即可。