android学习笔记33——资源ShapeDrawable
ShapeDrawable
ShapeDrawable用于定义一个基本的几何图像(如,矩形、圆形、线条.......)。
定义ShapeDrawable的XML文件的根元素是<shape.../>,该元素可指定如下属性:
android:shape=["rectangle"|"oval"|"ling"|"ring"]——指定定义那种类型的几何图形。

实例如下:椭圆、渐变背景的文本框
drawable资源文件==》 myshape1.xml==>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" > <!-- 设置填充颜色 -->
<solid android:color="#fff" />
<!-- 设置四周的内边距 -->
<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp" />
<!-- 设置边框 -->
<stroke
android:width="3dip"
android:color="#ff0" /> </shape> myshape2.xml==>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" > <!-- 定义填充渐变色 angle,角度 -->
<gradient
android:angle="45"
android:endColor="#80FF00FF"
android:startColor="#FFFF0000" />
<!-- 设置四周的内边距 -->
<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp" />
<!-- 设置圆角矩形 -->
<corners android:radius="8dp" /> </shape> myshape3.xml==>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" > <!-- 定义填充渐变色 -->
<gradient
android:angle="45"
android:endColor="#00f"
android:startColor="#ff0"
android:type="sweep" />
<!-- 设置四周的内边距 -->
<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp" />
<!-- 设置圆角矩形 -->
<corners android:radius="8dp" /> </shape> 布局文件==》
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" > <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/myshape1" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/myshape2" /> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/myshape3" />
</LinearLayout>
运行效果:

android学习笔记33——资源ShapeDrawable的更多相关文章
- android学习笔记32——资源
Android应用资源 资源分类: 1.无法直接访问的原生资源,保存于asset目录下 2.可通过R资源清单类访问的资源,保存于res目录下 资源的类型以及存储方式 android要求在res目录下用 ...
- Android学习笔记菜单资源文件
创建菜单资源 menu_one.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns: ...
- Android学习笔记样式资源文件
样式资源和主题资源都是写在styles.xml文件里面的 <style name="title"> <item name="android:textSi ...
- Android学习笔记数组资源文件
在android中我们可以通过数组资源文件,定义数组元素. 数组资源文件是位于values目录下的 array.xml <?xml version="1.0" encodin ...
- Android学习笔记尺寸资源
尺寸资源语法 dp:设备独立资源像素 会根据设备匹配大小 一般用于设置边距和组件大小 sp : 可伸缩像素 根据用户手机字体大小首选项进行缩放 使用尺寸资源 定义尺寸资源 dimens <?xm ...
- Android学习笔记颜色资源文件
资源文件目录 颜色资源文件格式 colors.xml <?xml version="1.0" encoding="utf-8"?> <reso ...
- 【转】Pro Android学习笔记(四):了解Android资源(下)
处理任意的XML文件 自定义的xml文件放置在res/xml/下,可以通过R.xml.file_name来获取一个XMLResourceParser对象.下面是xml文件的例子: <rootna ...
- 【转】Pro Android学习笔记(三):了解Android资源(上)
在Android开发中,资源包括文件或者值,它们和执行应用捆绑,无需在源代码中写死,因此我们可以改变或替换他们,而无需对应用重新编译. 了解资源构成 参考阅读Android学习笔记(三八):资源res ...
- Android学习笔记36:使用SQLite方式存储数据
在Android中一共提供了5种数据存储方式,分别为: (1)Files:通过FileInputStream和FileOutputStream对文件进行操作.具体使用方法可以参阅博文<Andro ...
随机推荐
- Install Fastx (zz)
Fastx-toolkit installation on CentOS ===================================== Tested on CentOS release ...
- MySql配置方法,批处理进行MySql配置
@echo 注意右击管理员运行 @pause @echo .添加环境变量 @echo .my.ini中添加如下配置 @echo [mysqld] @echo basedir=C:\Program Fi ...
- [转载] 已知strcpy的函数原型:char *strcpy(char *strDest, const char *strSrc),编写函数 strcpy(C++版)
已知strcpy的函数原型:char *strcpy(char *strDest, const char *strSrc)其中strDest 是目的字符串,strSrc 是源字符串.不调用C++/C ...
- RelativeLayout用到的一些重要的属性
第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ...
- URAL 1176 Hyperchannels(欧拉回路路径)
Hyperchannels Time limit: 1.0 secondMemory limit: 64 MB The Galaxy Empire consists of N planets. Hyp ...
- timus 1210 Kind Spirits(最短路)(动态规划)
Kind Spirits Time limit: 1.0 secondMemory limit: 64 MB Ivanushka the Fool lives at the planet of 0-l ...
- 配置DNS
1.将DNS解析服务器添加到:/etc/resolv.conf 2.打开DNS相关配置:sed -i 's/^hosts:[ \t]*files[ \t]*$/& dns/' /etc/nss ...
- 嵌入式Linux开发——内容介绍与开发环境的搭建
嵌入式Linux开发步骤 设计自己的硬件系统 编写Bootloader 裁剪自己的Linux内核 开发移植设备驱动 构建根文件系统 开发应用程序 嵌入式Linux学习要点 熟练使用开发工具和相关指令集 ...
- Linux平台下利用系统接口函数按照行读写文件
要求:支持大文件(1M)一次性读入 源代码如下: #include<stdio.h> #include<fcntl.h> #include<stdlib.h> #i ...
- faster rcnn test demo ---repaired for video input and save the image, label, score et al. into .mat format
faster rcnn test demo ---repaired for video input and save the image, label, score et al. into .mat ...