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 ...
随机推荐
- word文档快速取消图片的链接
快捷键Ctrl+Shift+F9 首先,Ctrl+A全选文章或者用鼠标拖动的方法选中部分文中: 批量删除word文档中的超级链接然后,同时按下键盘上的Ctrl+Shift+F9. 效果就出现了! 宏方 ...
- eclipse 发布APK
在程序代码告一段落后,需要发布程序,以后还有后续版本更新,用户下载后自动提示更新. 但是平时测试都是debug的方式安装了,但是一个程序不可能是一个人在做,所以生成的密钥都是不一样的, 这就造成用户需 ...
- 比较compareTo与equals及==的区别
1.compareTo: 附上:源码: public int compareTo(String anotherString) { int len1 = value.length; ...
- jQuery停止动画和判断是否处于动画状态
1.停止元素的动画 stop([clearQueue][,gotoEnd]); 参数clearQHCHC和gotoEnd都足町选的参数,为Boolean值(ture或flase).clearQueue ...
- dbcp基本配置和重连配置 -- mysql 8小时自动断开连接的问题
1. 引入dbcp (选择1.4) Java代码 com.alibaba.external jakarta.commons.dbcp 1.4 2. dbcp的基本配置 相关配置说明: initia ...
- Spring MVC数组绑定
需求:商品批量删除,用户在页面选择多个商品,批量删除. 关键:将页面选择(多选)的商品id,传到controller方法的形参,方法形参使用数组接收页面请求的多个商品id // 批量删除 商品信息 @ ...
- URAL 1176 Hyperchannels(欧拉回路路径)
Hyperchannels Time limit: 1.0 secondMemory limit: 64 MB The Galaxy Empire consists of N planets. Hyp ...
- MySql中的skip-name-resovle
mysql用的一直很好用,有一次断网了,发现连接虚拟机里的mysql特别费劲,几经扔腾,才知道是因为断网以后,名字解析这块有点问题,在my.cnf文件中加了一条skip-name-resovle,果断 ...
- 嵌入式Linux C笔试题积累(转)
http://blog.csdn.net/h_armony/article/details/6764811 1. 嵌入式系统中断服务子程序(ISR) 中断是嵌入式系统中重要的组成部分,这导致了很 ...
- 论文笔记之:Asynchronous Methods for Deep Reinforcement Learning
Asynchronous Methods for Deep Reinforcement Learning ICML 2016 深度强化学习最近被人发现貌似不太稳定,有人提出很多改善的方法,这些方法有很 ...