android-Drawable Resources
来源:互联网 发布:iphone手机称重软件 编辑:程序博客网 时间:2024/03/29 23:23
》 There are several different types of drawables:
Bitmap File,Nine-Patch File,Layer List,State List,Level List,Transition Drawable,Inset Drawable,Clip Drawable,Scale Drawable,Shape Drawable
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@[package:]drawable/drawable_resource" android:id="@[+][package:]id/resource_name" android:top="dimension" android:right="dimension" android:bottom="dimension" android:left="dimension" /></layer-list>
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <bitmap android:src="@drawable/android_red" android:gravity="center" /> </item> <item android:top="10dp" android:left="10dp"> <bitmap android:src="@drawable/android_green" android:gravity="center" /> </item> <item android:top="20dp" android:left="20dp"> <bitmap android:src="@drawable/android_blue" android:gravity="center" /> </item></layer-list>
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle" | "oval" | "line" | "ring"] > <corners android:radius="integer" android:topLeftRadius="integer" android:topRightRadius="integer" android:bottomLeftRadius="integer" android:bottomRightRadius="integer" /> <gradient android:angle="integer" android:centerX="integer" android:centerY="integer" android:centerColor="integer" android:endColor="color" android:gradientRadius="integer" android:startColor="color" android:type=["linear" | "radial" | "sweep"] android:useLevel=["true" | "false"] /> <padding android:left="integer" android:top="integer" android:right="integer" android:bottom="integer" /> <size android:width="integer" android:height="integer" /> <solid android:color="color" /> <stroke android:width="integer" android:color="color" android:dashWidth="integer" android:dashGap="integer" /></shape>》 XML file saved at
res/drawable/gradient_box.xml
:<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="45"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /></shape>
This layout XML applies the shape drawable to a View:
<TextView android:background="@drawable/gradient_box" android:layout_height="wrap_content" android:layout_width="wrap_content" />
This application code gets the shape drawable and applies it to a View:
Resources res =getResources()
;Drawable shape = res.getDrawable
(R.drawable.gradient_box);TextView tv = (TextView)findViewByID(R.id.textview);tv.setBackground(shape);
0 0
- Android Shape Drawable Resources
- Android Shape Drawable Resources
- android-Drawable Resources
- Android: Drawable Resources
- Android API Guides---Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- Drawable Resources
- 浅谈对android drawable resources 的研究
- Android Drawable Resources系列3:<layer-list>
- Android Drawable Resources系列4:<selector>
- Android Drawable Resources系列5:<level-list>
- Android Drawable Resources系列6:<transition>
- TestNG eclipse 插件安装
- 右值引用:模板参数推导和引用折叠
- 关于类模板特化的小知识
- android 实现无限循环viewpager
- 栈和队列之用一个栈实现另一个栈的排序
- android-Drawable Resources
- 数据挖掘基本模型一览
- iOS-Pch常用代码
- 求两个数的最大公约数算法
- 一个数据库多Instance的连接解决方案
- 一些有用的网站
- 一个linux下的简单的贪吃蛇游戏(链表)
- 当EditText是多行文本时, 光标如何设置在从左上角
- Scala学习第二十天 Scala中的本地函数与作为语言一等公民的函数详解