您的位置:首页 > 移动开发 > Android开发

Android学习笔记(一)——定义色图资源的圆角矩形

2012-11-19 16:59 204 查看
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、运行即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: