- 浏览: 580346 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (338)
- 已过时文章(留念用) (39)
- Android学习笔记 (30)
- Android开发指引自译 (100)
- Android NDK文档自译 (23)
- Android设计指引自译 (2)
- xp(ペケピー)&linux(理奈、铃)酱~ (4)
- ui酱&歌词自译~ (9)
- lua酱~ (9)
- 自我反省 (1)
- 羽game计划 (1)
- XSL酱 (2)
- java酱 (3)
- 设计的领悟 (58)
- 涂鸦作品(pixiv) (1)
- ruby酱 (2)
- Objective-C编程语言自译 (2)
- Android开发月报 (6)
- objc酱 (2)
- photoshop (3)
- js酱 (6)
- cpp酱 (8)
- antlr酱 (7)
- Lua 5.1参考手册自译 (11)
- 收藏品 (3)
- 待宵草计划 (4)
- 体验版截图 (1)
最新评论
-
naruto60:
太给力了!!!!我这网打不开Intel官网,多亏楼主贴了连接, ...
使用HAXM加速的Android x86模拟器(和一些问题) -
yangyile2011:
谢谢博主,翻译得很好哦
【翻译】(4)片段 -
ggwang:
牙痛的彼岸:痹!
牙痛的彼岸 -
ggwang:
总结得很简练清晰啊,学习了!
ANTLR学习笔记一:概念理解 -
leisurelife1990:
mk sdd
用git下载Android自带app的源代码
【翻译】(35)可绘画对象资源
see
http://developer.android.com/guide/topics/resources/drawable-resource.html
原文见
http://developer.android.com/guide/topics/resources/drawable-resource.html
-------------------------------
Drawable Resources
可绘画对象资源
-------------------------------
See also
另见
2D Graphics 二维图形
-------------------------------
A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon. There are several different types of drawables:
一个可绘画资源是一个用于图形的通用概念,它可以被绘画到屏幕,而且你可以用API诸如getDrawable(int)取出它,或者把它应用到另一个带有属性诸如android:drawable和android:icon的XML资源中。有几种不同类型的可绘画对象:
* Bitmap File
* 位图文件
A bitmap graphic file (.png, .jpg, or .gif). Creates a BitmapDrawable.
位图图形文件(.png,.jpg或.gif)。创建一个BitmapDrawable。
* Nine-Patch File
* 九宫文件
A PNG file with stretchable regions to allow image resizing based on content (.9.png). Creates a NinePatchDrawable.
一个PNG文件,带有可拉伸区域以允许图片基于内容来改变大小(.9.png)。创建一个NinePatchDrawable。
* Layer List
* 图层列表
A Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index is be drawn on top. Creates a LayerDrawable.
一个可绘画对象,管理其它Drawable的数组。它们依照数组顺序绘画,所以带有最大索引的元素被绘画在最顶。创建一个LayerDrawable。
* State List
* 状态列表
An XML file that references different bitmap graphics for different states (for example, to use a different image when a button is pressed). Creates a StateListDrawable.
一个XML文件,引用不同的位图图形以用于不同的状态(例如,当按钮被按下时使用不同的图片)。创建一个StateListDrawable。
* Level List
* 级别列表
An XML file that defines a drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Creates a LevelListDrawable.
一个XML文件,定义一个可绘画对象,它管理一定数量可选的Drawable,每个被赋予一个最大数值。创建一个LevelListDrawable。
* Transition Drawable
* 过渡可绘画对象
An XML file that defines a drawable that can cross-fade between two drawable resources. Creates a TransitionDrawable.
一个XML文件,定义一个可绘画对象,它可以在两个可绘画资源之间交叉淡入淡出。创建一个TransitionDrawable。
* Inset Drawable
* 内嵌可绘画对象
An XML file that defines a drawable that insets another drawable by a specified distance. This is useful when a View needs a background drawble that is smaller than the View's actual bounds.
一个XML文件,定义一个可绘画对象,它通过一个指定的距离内嵌另一个可绘画对象。当一个View需要一个背景图片小于View的实际范围时这很有用。
* Clip Drawable
* 剪裁可绘画资源
An XML file that defines a drawable that clips another Drawable based on this Drawable's current level value. Creates a ClipDrawable.
一个XML文件,定义一个可绘画资源,它剪裁另一个Drawable,基于这个Drawable的当前级别值。创建一个ClipDrawable。
* Scale Drawable
* 缩放可绘画资源
An XML file that defines a drawable that changes the size of another Drawable based on its current level value. Creates a ScaleDrawable
一个XML文件,定义一个可绘画对象,它改变另一个Drawable的大小,基于它的当前级别值。
* Shape Drawable
* 形状可绘画资源
An XML file that defines a geometric shape, including colors and gradients. Creates a ShapeDrawable.
一个XML文件,定义一个几何形状,包括颜色和渐变。创建一个ShapeDrawable。
Also see the Animation Resource document for how to create an AnimationDrawable.
另见动画资源文档以获取如何创建一个AnimationDrawable的信息。
-------------------------------
Note: A color resource can also be used as a drawable in XML. For example, when creating a state list drawable, you can reference a color resource for the android:drawable attribute (android:drawable="@color/green").
注意:一个颜色资源在XML中还可以用作一个可绘画对象。例如,当创建一个状态列表可绘画对象时,你可以对android:drawable属性引用一个颜色资源(android:drawable="@color/green")。
-------------------------------
-------------------------------
Bitmap
位图
A bitmap image. Android supports bitmap files in a three formats: .png (preferred), .jpg (acceptable), .gif (discouraged).
一个位图图片。Android支持三种格式的位图文件:.png(首选),.jpg(可接受),.gif(不鼓励)
You can reference a bitmap file directly, using the filename as the resource ID, or create an alias resource ID in XML.
你可以使用文件名作为资源ID来直接引用一个位图文件,或者在XML中创建一个别名资源ID。
-------------------------------
Note: Bitmap files may be automatically optimized with lossless image compression by the aapt tool during the build process. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build. If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized.
注意:位图文件可能在构建过程中被aapt工具自动优化为无损的图片压缩。例如,一个不需要多于256色的真彩PNG可能被转换为一个8位PNG,带有一个调色板。这将产生一个相同质量的图片,但需要较少的内存。所以请意识到放置在这个目录下的图片二进制文件可能在构建期间改变。如果你打算读取一个图片作为一个位流,以便转换它为一个位图,请改为放置你的图片在res/raw/目录,那里它们将不会被优化。
-------------------------------
Bitmap File
位图文件
A bitmap file is a .png, .jpg, or .gif file. Android creates a Drawable resource for any of these files when you save them in the res/drawable/ directory.
一个位图文件是一个.png,.jpg,或.gif文件。当你把它们保存在res/drawable/目录中时,Android为这些文件的任意一个创建Drawable资源。
* file location:
* 文件位置:
res/drawable/filename.png (.png, .jpg, or .gif)
res/drawable/<文件名>.png (.png, .jpg或.gif)
The filename is used as the resource ID.
文件名用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a BitmapDrawable.
指向一个BitmapDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中: @[<包名>:]drawable/<文件名>
* example:
* 示例:
With an image saved at res/drawable/myimage.png, this layout XML applies the image to a View:
伴随保存为res/drawable/myimage.png的图片,这个布局XML应用该图片到一个View。
-------------------------------
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/myimage" />
-------------------------------
The following application code retrieves the image as a Drawable:
以下应用程序代码取出图片作为一个Drawable。
-------------------------------
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);
-------------------------------
* see also:
* 另见
* 2D Graphics 二维图形
* BitmapDrawable
XML Bitmap
XML位图
An XML bitmap is a resource defined in XML that points to a bitmap file. The effect is an alias for a raw bitmap file. The XML can specify additional properties for the bitmap such as dithering and tiling.
XML位图是一个定义在XML中的资源,它指向一个位图文件。效果是用于原始位图文件的一个别名。XML可以为位图指定额外的属性,诸如抖动和平铺。
-------------------------------
Note: You can use a <bitmap> element as a child of an <item> element. For example, when creating a state list or layer list, you can exclude the android:drawable attribute from an <item> element and nest a <bitmap> inside it that defines the drawable item.
注意:你可以使用<bitmap>元素作为<item>元素的子元素。例如,当创建一个状态列表或图层列表时,你可以从一个<item>中排除android:drawable属性,并且在它里面内嵌一个定义可绘画对象条目的<bitmap>。
-------------------------------
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a BitmapDrawable.
指向一个BitmapDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中: R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@[package:]drawable/drawable_resource"
android:antialias=["true" | "false"]
android:dither=["true" | "false"]
android:filter=["true" | "false"]
android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"]
android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />
-------------------------------
* elements:
* 元素:
* <bitmap>
Defines the bitmap source and its properties.
定义位图源和它的属性。
* attributes:
* xmlns:android
String. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android". This is required only if the <bitmap> is the root element—it is not needed when the <bitmap> is nested inside an <item>.
字符串。定义XML名字空间,必须为"http://schemas.android.com/apk/res/android"。必需的,仅当<bitmap>为根元素——当<bitmap>嵌套在一个<item>中时不需要。
* android:src
Drawable resource. Required. Reference to a drawable resource.
可绘画资源。必需的。对可绘画资源的引用。
* android:antialias
Boolean. Enables or disables antialiasing.
布尔型。使能和关闭抗锯齿。
* android:dither
Boolean. Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen).
布尔型。使能或关闭位图的抖动,如果位图没有和屏幕相同的像素配置(例如:一个ARGB 8888位图对应一个RGB 565屏幕)。(注:数字标识通道的位数)
* android:filter
Boolean. Enables or disables bitmap filtering. Filtering is used when the bitmap is shrunk or stretched to smooth its apperance.
布尔型。使能或关闭位图滤镜。当位图被缩小或拉伸时使用滤镜以平滑它的显示。
* android:gravity
Keyword. Defines the gravity for the bitmap. The gravity indicates where to position the drawable in its container if the bitmap is smaller than the container.
关键词。定义位图的重力。重力指示把可绘画对象放在容器中的哪里,如果位图小于容器。
Must be one or more (separated by '|') of the following constant values:
必须是以下常量值中的一个或多个(用'|'分隔)。
-------------------------------
* Value Description
* 值 描述
* top Put the object at the top of its container, not changing its size.
* top 放置对象在它的容器顶部,不改变它的大小。
* bottom Put the object at the bottom of its container, not changing its size.
* bottom 放置对象在它的容器底部,不改变它的大小。
* left Put the object at the left edge of its container, not changing its size.
* left 放置对象在它的容器左边沿,不改变它的大小。
* right Put the object at the right edge of its container, not changing its size.
* right 放置对象在它的容器右边沿,不改变它的大小。
* center_vertical Place object in the vertical center of its container, not changing its size.
* center_vertical 放置对象在它的容器的垂直居中,不改变它的大小。
* fill_vertical Grow the vertical size of the object if needed so it completely fills its container.
* fill_vertical 如果需要的话增加对象的垂直大小,使它完全填充它的容器。
* center_horizontal Place object in the horizontal center of its container, not changing its size.
* center_horizontal 放置对象在它的容器的水平居中,不改变它的大小。
* fill_horizontal Grow the horizontal size of the object if needed so it completely fills its container.
* fill_vertical 如果需要的话增加对象的水平大小,使它完全填充它的容器。
* center Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
* center 把对象放置在它的容器的垂直和水平轴方向上的中间,不改变它的大小。
* fill Grow the horizontal and vertical size of the object if needed so it completely fills its container. This is the default.
* fill 如果需要的话增加对象的水平和垂直大小,使它完全填充它的容器。它是默认的。
* clip_vertical Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
* clip_vertical 额外选项,可以设置它,让子对象的上和/或下边沿剪裁为它的容器的范围。剪裁基于垂直重力:上重力剪裁下边沿,下重力剪裁上边沿,而两者都不是则剪裁两个边沿。
* clip_horizontal Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.
* clip_horizontal 额外选项,可以设置它,让子对象的左和/或右边沿剪裁为它的容器的范围。剪裁基于垂直重力:左重力剪裁右边沿,右重力剪裁左边沿,而两者都不是则剪裁两个边沿。
-------------------------------
* android:tileMode
Keyword. Defines the tile mode. When the tile mode is enabled, the bitmap is repeated. Gravity is ignored when the tile mode is enabled.
关键词。定义平铺模式。当平铺模式开启时,位图被重复。当平铺模式使能时重力被忽略。
Must be one of the following constant values:
必须是以下常量值之一:
-------------------------------
* Value Description
* 值 描述
* disabled Do not tile the bitmap. This is the default value.
* disabled 不平铺位图。这是默认值
* clamp Replicates the edge color if the shader draws outside of its original bounds
* clamp 复制边沿颜色,如果着色器在它的原来范围的外面绘画(注:clamp的原意是夹住,固定)
* repeat Repeats the shader's image horizontally and vertically.
* repeat 水平和垂直地重复着色器的图片
* mirror Repeats the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
* mirror 水平和垂直地重复着色器的图片,交替地镜像图片使相邻的图片总是缝合在一起。
-------------------------------
* example:
* 示例:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/icon"
android:tileMode="repeat" />
-------------------------------
* see also:
* 另见
* BitmapDrawable
* Creating alias resources 创建别名资源
-------------------------------
Nine-Patch
九宫
A NinePatch is a PNG image in which you can define stretchable regions that Android scales when content within the View exceeds the normal image bounds. You typically assign this type of image as the background of a View that has at least one dimension set to "wrap_content", and when the View grows to accomodate the content, the Nine-Patch image is also scaled to match the size of the View. An example use of a Nine-Patch image is the background used by Android's standard Button widget, which must stretch to accommodate the text (or image) inside the button.
一个NinePatch是一个PNG图片,你可以在它里面定义可拉伸区域,当View里的内容超出正常图片范围时,Android缩放该区域。通常你设计此类型图片作为有至少一个尺寸设置为"wrap_content"的View的背景,并且当View增大以容纳内容时,九宫图片还被缩放以匹配View的大小。使用一个九宫图片的示例是被Android的标准Button部件使用的背景,它必须缩放以容纳按钮中的文本(或图片)。
Same as with a normal bitmap, you can reference a Nine-Patch file directly or from a resource defined by XML.
与使用一个普通的位图相同,你可以直接引用一个九宫文件或从XML定义的资源中引用。
For a complete discussion about how to create a Nine-Patch file with stretchable regions, see the 2D Graphics document.
想获取关于如何用可拉伸的区域创建一个九宫文件的完整讨论,请参见二维图形文档。
Nine-Patch File
九宫文件
* file location:
* 文件位置:
res/drawable/filename.9.png
res/drawable/<文件名>.9.png
The filename is used as the resource ID.
文件名用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a NinePatchDrawable.
指向一个NinePatchDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中: @[<包名>:]drawable/<文件名>
* example:
* 示例:
With an image saved at res/drawable/myninepatch.9.png, this layout XML applies the Nine-Patch to a View:
使用保存为res/drawable/myninepatch.9.png的图片,这个布局XML应用九宫到一个View:
-------------------------------
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/myninepatch" />
-------------------------------
* see also:
* 另见
* 2D Graphics 二维图形
* NinePatchDrawable
XML Nine-Patch
XML九宫
An XML Nine-Patch is a resource defined in XML that points to a Nine-Patch file. The XML can specify dithering for the image.
一个XML九宫是一个定义在XML中的资源,它指向一个九宫文件。XML可以指定图片的抖动。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a NinePatchDrawable.
指向一个NinePatchDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中: @[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@[package:]drawable/drawable_resource"
android:dither=["true" | "false"] />
-------------------------------
* elements:
* 元素:
* <nine-patch>
Defines the Nine-Patch source and its properties.
定义九宫资源和它的属性。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* android:src
Drawable resource. Required. Reference to a Nine-Patch file.
可绘画对象资源。必需的。指向一个九宫文件的引用。
* android:dither
Boolean. Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen).
布尔型。使能或屏蔽位图的抖动,如果位图没有和屏幕相同的像素配置(例如:一个ARGB 8888位图用在一个RGB 565屏幕上)。
* example:
* 示例:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/myninepatch"
android:dither="false" />
-------------------------------
-------------------------------
Layer List
图层列表
A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.
一个LayerDrawable是一个可绘画对象,它管理其它可绘画对象的数组。列表中每个可绘画对象依照列表中的顺序被绘画——列表中最后的可绘画对象被绘画在最顶。
Each drawable is represented by an <item> element inside a single <layer-list> element.
每个可绘画对象由一个单一<layer-list>元素内的<item>元素代表。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a LayerDrawable.
指向一个LayerDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中: @[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?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>
-------------------------------
* elements:
* 元素:
* <layer-list>
Required. This must be the root element. Contains one or more <item> elements.
必需的。它必须是根元素。包含一个或多个<item>元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间。必须是"http://schemas.android.com/apk/res/android"。
* <item>
Defines a drawable to place in the layer drawable, in a position defined by its attributes. Must be a child of a <selector> element. Accepts child <bitmap> elements.
定义一个可绘画对象以放在图层可绘画对象中,在它的属性定义的位置中。必须是一个<selector>元素的子元素。接受子<bitmap>元素。
* attributes:
* 属性:
* android:drawable
Drawable resource. Required. Reference to a drawable resource.
可绘画对象资源。必需的。指向一个可绘画对象资源的引用。
* android:id
Resource ID. A unique resource ID for this drawable. To create a new resource ID for this item, use the form: "@+id/name". The plus symbol indicates that this should be created as a new ID. You can use this identifier to retrieve and modify the drawable with View.findViewById() or Activity.findViewById().
资源ID。这个可绘画对象的唯一资源ID。为了为这个条目创建一个新的资源ID,使用此格式:"@+id/<名称>"。加号指示它应该被创建作为一个新ID。你可以用View.findViewById()或Activity.findViewById()使用这个标识符取出并修改可绘画对象。
* android:top
Integer. The top offset in pixels.
整型。上偏移,单位像素。
* android:right
Integer. The right offset in pixels.
整型。右偏移,单位像素。
* android:bottom
Integer. The bottom offset in pixels.
整型。下偏移,单位像素。
* android:left
Integer. The left offset in pixels.
整型。左偏移,单位像素。
All drawable items are scaled to fit the size of the containing View, by default. Thus, placing your images in a layer list at different positions might increase the size of the View and some images scale as appropriate. To avoid scaling items in the list, use a <bitmap> element inside the <item> element to specify the drawable and define the gravity to something that does not scale, such as "center". For example, the following <item> defines an item that scales to fit its container View:
默认下,所有可绘画对象条目被缩放以适应容器View的大小。因此,放置你的图片在一个图层列表的不同位置可能增加View的大小,并且一些图片合理地缩放。为了避免缩放列表中条目,在<item>元素内使用<bitmap>元素以指定可绘画对象,并且定义重力为某个不会被缩放的选项,诸如"center"。例如,以下<item>定义一个条目,它缩放以适应它的容器View:
-------------------------------
<item android:drawable="@drawable/image" />
-------------------------------
To avoid scaling, the following example uses a <bitmap> element with centered gravity:
为了避免缩放,以下示例使用一个<bitmap>元素,带有居中的重力:
-------------------------------
<item>
<bitmap android:src="@drawable/image"
android:gravity="center" />
</item>
-------------------------------
* example:
* 示例:
XML file saved at res/drawable/layers.xml:
保存为res/drawable/layers.xml的XML文件:
-------------------------------
<?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>
-------------------------------
Notice that this example uses a nested <bitmap> element to define the drawable resource for each item with a "center" gravity. This ensures that none of the images are scaled to fit the size of the container, due to resizing caused by the offset images.
注意,这个示例使用一个嵌套的<bitmap>元素以为每个条目定义可绘画对象资源,带"center"重力。它确保没有图片被缩放以适应容器的大小,因为偏移图片会导致重新改变大小。
This layout XML applies the drawable to a View:
这个布局XML把可绘画对象应用到一个View:
-------------------------------
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/layers" />
-------------------------------
The result is a stack of increasingly offset images:
结果是一堆逐渐偏移的图片:
(图略:
三个机器人向右下角堆叠起来,分别是红、绿、蓝。
)
* see also:
* 另见:
* LayerDrawable
-------------------------------
State List
状态列表
A StateListDrawable is a drawable object defined in XML that uses a several different images to represent the same graphic, depending on the state of the object. For example, a Button widget can exist in one of several different states (pressed, focused, or niether) and, using a state list drawable, you can provide a different background image for each state.
一个StateListDrawable是定义在XML中的可绘画对象,它使用几个不同的图片以表现相同图形,依赖于对象的状态。例如,一个Button部件可以存在于一个或几个不同的状态(按下,获取焦点,或都不是)(注:应作neither),并且你可以通过使用一个状态列表可绘画对象,为各个状态提供一个不同的背景图片。
You can describe the state list in an XML file. Each graphic is represented by an <item> element inside a single <selector> element. Each <item> uses various attributes to describe the state in which it should be used as the graphic for the drawable.
你可以在一个XML文件中描述状态列表。每个图形由一个单一<selector>元素内的<item>元素代表。每个<item>使用不同属性以描述它应该被使用作为可绘画对象的图形时的状态。
During each state change, the state list is traversed top to bottom and the first item that matches the current state is used—the selection is not based on the "best match," but simply the first item that meets the minimum criteria of the state.
在每个状态改变期间,状态列表被从上而下遍历,并且第一个匹配当前状态的条目被使用——选择不是基于“最佳匹配”,只是简单地选择满足状态最低标准的第一个条目。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a StateListDrawable.
指向一个StateListDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize=["true" | "false"]
android:dither=["true" | "false"]
android:variablePadding=["true" | "false"] >
<item
android:drawable="@[package:]drawable/drawable_resource"
android:state_pressed=["true" | "false"]
android:state_focused=["true" | "false"]
android:state_hovered=["true" | "false"]
android:state_selected=["true" | "false"]
android:state_checkable=["true" | "false"]
android:state_checked=["true" | "false"]
android:state_enabled=["true" | "false"]
android:state_activated=["true" | "false"]
android:state_window_focused=["true" | "false"] />
</selector>
-------------------------------
* elements:
* 元素:
* <selector>
Required. This must be the root element. Contains one or more <item> elements.
必需的。它必须是根元素。包含一个或多个<item>元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* android:constantSize
Boolean. "true" if the drawable's reported internal size remains constant as the state changes (the size is the maximum of all of the states); "false" if the size varies based on the current state. Default is false.
布尔型。"true"如果当状态改变时可绘画对象的被报告的内部大小保持常量(大小是所有状态的最大值);"false"如果大小基于当前状态而改变。默认为false。
* android:dither
Boolean. "true" to enable dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance, an ARGB 8888 bitmap with an RGB 565 screen); "false" to disable dithering. Default is true.
布尔型。"true"以使能位图的抖动,如果位图没有与屏幕相同的像素配置(例如,一个ARGB 8888位图用在一个RGB 565屏幕上);"false"以关闭抖动。默认为true。
* android:variablePadding
Boolean. "true" if the drawable's padding should change based on the current state that is selected; "false" if the padding should stay the same (based on the maximum padding of all the states). Enabling this feature requires that you deal with performing layout when the state changes, which is often not supported. Default is false.
布尔型。"true"如果可绘画大小的内边距应该改变,基于被选择的当前状态。"false"如果内边距应该保持相同(基于所有状态的最大内边距)。使能这个特性需要你在状态改变时处理执行的布局,这常常是不被支持的。默认为false。
* <item>
Defines a drawable to use during certain states, as described by its attributes. Must be a child of a <selector> element.
定义一个可绘画对象以在某个状态期间使用,正如它的属性所描述的那样。必须是<selector>元素的子元素。
* attributes:
* 属性:
* android:drawable
Drawable resource. Required. Reference to a drawable resource.
可绘画资源。必需的。指向一个可绘画资源的引用。
* android:state_pressed
Boolean. "true" if this item should be used when the object is pressed (such as when a button is touched/clicked); "false" if this item should be used in the default, non-pressed state.
布尔型。"true"如果当对象被按下时这个条目应该被使用(诸如按钮被触碰/点击);"false"如果默认非按下状态这个条目应该被使用。
* android:state_focused
Boolean. "true" if this item should be used when the object has input focus (such as when the user selects a text input); "false" if this item should be used in the default, non-focused state.
布尔型。"true"如果当对象拥有输入焦点时这个条目应该被使用(诸如当用户选择一个文本输入);"false"如果默认非焦点状态下这个条目应该被使用。
* android:state_hovered
Boolean. "true" if this item should be used when the object is being hovered by a cursor; "false" if this item should be used in the default, non-hovered state. Often, this drawable may be the same drawable used for the "focused" state.
布尔型。"true"如果当对象被一个光标悬停时这个条目应该被使用;"false"如果默认非悬停状态这个条目应该被使用。通常,可绘画对象可以和“焦点”状态使用同一个可绘画对象。
Introduced in API level 14.
在API级别14中引入。
* android:state_selected
Boolean. "true" if this item should be used when the object is the current user selection when navigating with a directional control (such as when navigating through a list with a d-pad); "false" if this item should be used when the object is not selected.
布尔型。"true"如果当对象是当前用户的选择时条目应该被使用,当用方向控制导航时(诸如当使用一个方向板导航通过一个列表时);"false"如果当它未选中时这个条目应该被使用。
The selected state is used when focus (android:state_focused) is not sufficient (such as when list view has focus and an item within it is selected with a d-pad).
当焦点(android:state_focused)不足够时使用选中状态(诸如当列表视图拥有焦点,并且它里面的一个条目用一个方向板被选中)。
* android:state_checkable
Boolean. "true" if this item should be used when the object is checkable; "false" if this item should be used when the object is not checkable. (Only useful if the object can transition between a checkable and non-checkable widget.)
布尔型。"true"如果当对象是可勾选时条目应该被使用;"false"如果当对象不可勾选时这个条目应该被使用。(仅当对象可以在可勾选和不可勾选部件之间过渡时才有用。)
* android:state_checked
Boolean. "true" if this item should be used when the object is checked; "false" if it should be used when the object is un-checked.
布尔型。"true"如果当对象被勾选时这个条目应该被使用;"false"如果当对象不被勾选时它应该被使用。
* android:state_enabled
Boolean. "true" if this item should be used when the object is enabled (capable of receiving touch/click events); "false" if it should be used when the object is disabled.
布尔型。"true"如果当对象被使能时这个条目应该被使用(可以接收触碰/点击事件);"false"如果当对象被屏蔽时它应该被使用。
* android:state_activated
Boolean. "true" if this item should be used when the object is activated as the persistent selection (such as to "highlight" the previously selected list item in a persistent navigation view); "false" if it should be used when the object is not activated.
布尔型。"true"如果当对象被激活作为持久选择时这个条目应该被使用(诸如在一个持久导航视图中“高亮”前一个被选择的列表条目);"false"如果当对象不被激活时它应该被使用。
Introduced in API level 11.
在API级别11中引入。
* android:state_window_focused
Boolean. "true" if this item should be used when the application window has focus (the application is in the foreground), "false" if this item should be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears).
布尔型。"true"如果当应用程序窗口拥有焦点时这个条目应该被使用(应用程序在前台),"false"如果当应用程序窗口没有焦点时这个条目应该被使用(例如,如果通知窗帘被拉下或一个对话框出现)。
-------------------------------
Note: Remember that Android applies the first item in the state list that matches the current state of the object. So, if the first item in the list contains none of the state attributes above, then it is applied every time, which is why your default value should always be last (as demonstrated in the following example).
注意:记住Android应用状态列表中的第一个匹配对象当前状态的条目。所以,如果列表中第一个条目没有包含上述状态属性,那么它每次都被应用,这就是为什么你的默认值应该总是在最后(正如下面的示例演示的那样)。
-------------------------------
* example:
* 示例:
XML file saved at res/drawable/button.xml:
保存为res/drawable/button.xml的XML文件:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed --> <!-- 按下 -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused --> <!-- 获取焦点 -->
<item android:state_hovered="true"
android:drawable="@drawable/button_focused" /> <!-- hovered --> <!-- 悬停 -->
<item android:drawable="@drawable/button_normal" /> <!-- default --> <!-- 默认 -->
</selector>
-------------------------------
This layout XML applies the state list drawable to a Button:
这个布局XML把状态列表可绘画对象应用到一个Button:
-------------------------------
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/button" />
-------------------------------
* see also:
* 另见:
* StateListDrawable
-------------------------------
Level List
级别列表
A Drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the drawable with setLevel() loads the drawable resource in the level list that has a android:maxLevel value greater than or equal to the value passed to the method.
一个可绘画对象,管理一定数量可选的Drawable,每个被赋予一个最大数值。用setLevel()设置可绘画对象的级别值会加载级别列表中拥有一个android:maxLevel值大于或等于传递给该方法的值的可绘画对象。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a LevelListDrawable.
指向一个LevelListDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<level-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/drawable_resource"
android:maxLevel="integer"
android:minLevel="integer" />
</level-list>
-------------------------------
* elements:
* 元素:
* <level-list>
This must be the root element. Contains one or more <item> elements.
它必须是根元素。包含一个或多个<item>元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* <item>
Defines a drawable to use at a certain level.
定义一个用在某个级别上的可绘画对象。
* attributes:
* 属性:
* android:drawable
Drawable resource. Required. Reference to a drawable resource to be inset.
可绘画对象资源。必需的。指向被内嵌的可绘画对象资源的引用。
* android:maxLevel
Integer. The maximum level allowed for this item.
整型。这个条目允许的最大级别。
* android:minLevel
Integer. The minimum level allowed for this item.
整型。这个条目允许的最小级别。
* example:
* 示例:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/status_off"
android:maxLevel="0" />
<item
android:drawable="@drawable/status_on"
android:maxLevel="1" />
</level-list>
-------------------------------
Once this is applied to a View, the level can be changed with setLevel() or setImageLevel().
一旦它被应用到一个View时,级别可以用setLevel()或setImageLevel()来改变。
* see also:
* 另见:
LevelListDrawable
-------------------------------
Transition Drawable
过渡可绘画对象
A TransitionDrawable is a drawable object that can cross-fade between the two drawable resources.
一个TransitionDrawable是可绘画对象,可以在两个可绘画对象资源之间交叉淡入淡出。
Each drawable is represented by an <item> element inside a single <transition> element. No more than two items are supported. To transition forward, call startTransition(). To transition backward, call reverseTransition().
每个可绘画对象由单一<transition>元素内的<item>元素代表。支持不多于两个条目。为了向前过渡,请调用startTransition()。为了向后过渡,请调用reverseTransition()。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a TransitionDrawable.
指向一个TransitionDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<transition
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" />
</transition>
-------------------------------
* elements:
* 元素:
* <transition>
Required. This must be the root element. Contains one or more <item> elements.
必需的。它必须是根元素。包含一个或多个<item>元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* <item>
Defines a drawable to use as part of the drawable transition. Must be a child of a <transition> element. Accepts child <bitmap> elements.
定义一个可绘画对象,用作可绘画对象过渡的一部分。必须是<transition>元素的子元素。接受子<bitmap>元素。
* attributes:
* 属性:
* android:drawable
Drawable resource. Required. Reference to a drawable resource.
可绘画对象资源。必需的。指向一个可绘画对象资源的引用。
* android:id
Resource ID. A unique resource ID for this drawable. To create a new resource ID for this item, use the form: "@+id/name". The plus symbol indicates that this should be created as a new ID. You can use this identifier to retrieve and modify the drawable with View.findViewById() or Activity.findViewById().
资源ID。这个可绘画对象的唯一资源ID。为了为这个条目增加一个新的资源ID,使用这种格式:"@+id/<名称>"。加号指示它应该创建为一个新的ID。你可以用View.findViewById()或Activity.findViewById()使用这个指示符取出并修改可绘画对象。
* android:top
Integer. The top offset in pixels.
整型。上偏移,单位像素。
* android:right
Integer. The right offset in pixels.
整型。右偏移,单位像素。
* android:bottom
Integer. The bottom offset in pixels.
整型。下偏移,单位像素。
* android:left
Integer. The left offset in pixels.
整型。左偏移,单位像素。
* example:
* 示例:
XML file saved at res/drawable/transition.xml:
保存为res/drawable/transition.xml的XML文件:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/on" />
<item android:drawable="@drawable/off" />
</transition>
-------------------------------
This layout XML applies the drawable to a View:
这个布局XML把可绘画对象应用到一个View:
-------------------------------
<ImageButton
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/transition" />
-------------------------------
And the following code performs a 500ms transition from the first item to the second:
并且下面的代码执行一个500毫秒的过渡,从第一个条目到第二个条目:
-------------------------------
ImageButton button = (ImageButton) findViewById(R.id.button);
TransitionDrawable drawable = (TransitionDrawable) button.getDrawable();
drawable.startTransition(500);
-------------------------------
* see also:
* 另见
* TransitionDrawable
-------------------------------
Inset Drawable
内嵌可绘画对象
A drawable defined in XML that insets another drawable by a specified distance. This is useful when a View needs a background that is smaller than the View's actual bounds.
一个定义在XML中的可绘画对象,它以指定距离内嵌入另一个可绘画对象。这很有用,当一个View需要一个背景小于View的实际范围时。(注:这里的inset可能是指offset的反义词)
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a InsetDrawable.
指向一个InsetDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/drawable_resource"
android:insetTop="dimension"
android:insetRight="dimension"
android:insetBottom="dimension"
android:insetLeft="dimension" />
-------------------------------
* elements:
* 元素:
* <inset>
Defines the inset drawable. This must be the root element.
定义内嵌可绘画对象。它必须是根元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* android:drawable
Drawable resource. Required. Reference to a drawable resource to be inset.
可绘画对象资源。必需的。引用一个要被内嵌的可绘画对象资源。
* android:insetTop
Dimension. The top inset, as a dimension value or dimension resource
尺寸。上内嵌,作为尺寸值或尺寸资源
* android:insetRight
Dimension. The right inset, as a dimension value or dimension resource
尺寸。右内嵌,作为尺寸值或尺寸资源
* android:insetBottom
Dimension. The bottom inset, as a dimension value or dimension resource
尺寸。下内嵌,作为尺寸值或尺寸资源
* android:insetLeft
Dimension. The left inset, as a dimension value or dimension resource
尺寸。左内嵌,作为尺寸值或尺寸资源
* example:
* 示例:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/background"
android:insetTop="10dp"
android:insetLeft="10dp" />
-------------------------------
* see also:
* 另见:
* InsetDrawable
-------------------------------
Clip Drawable
剪裁可绘画对象
A drawable defined in XML that clips another drawable based on this Drawable's current level. You can control how much the child drawable gets clipped in width and height based on the level, as well as a gravity to control where it is placed in its overall container. Most often used to implement things like progress bars.
一个定义在XML中的可绘画对象,它剪裁其它可绘画对象,基于这个Drawable的当前级别。你可以控制子可绘画对象在宽度和高度方向上基于级别被剪裁多少,以及用于控制它被放置在它的整个容器中的哪里的重力。最常用于实现像进度条那样的东西。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名用作资源ID。
* compiled resource datatype:
被编译的资源数据类型:
Resource pointer to a ClipDrawable.
指向一个ClipDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<clip
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/drawable_resource"
android:clipOrientation=["horizontal" | "vertical"]
android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"] />
-------------------------------
* elements:
* 元素:
* <clip>
Defines the clip drawable. This must be the root element.
定义剪裁可绘画对象。它必须是根元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* android:drawable
Drawable resource. Required. Reference to a drawable resource to be clipped.
可绘画对象资源。必需的。指向一个要被剪裁的可绘画资源的引用。
* android:clipOrientation
Keyword. The orientation for the clip.
关键词。剪裁的方向。
Must be one of the following constant values:
必须是以下常量值之一:
-------------------------------
* Value Description
* 值 描述
* horizontal Clip the drawable horizontally.
* horizontal 水平地剪裁可绘画对象
* vertical Clip the drawable vertically.
* vertical 垂直地剪裁可绘画对象
-------------------------------
* android:gravity
Keyword. Specifies where to clip within the drawable.
关键词。指定在可绘画对象内的哪里剪裁。
Must be one or more (separated by '|') of the following constant values:
必须是以下常量值中的一个或多个(用'|'分隔):
-------------------------------
* Value Description
* 值 描述
* top Put the object at the top of its container, not changing its size. When clipOrientation is "vertical", clipping occurs at the bottom of the drawable.
* top 放置对象在它的容器的顶部,不改变它的大小。当clipOrientation为"vertical"时,剪裁发生在可绘画对象的底部。
* bottom Put the object at the bottom of its container, not changing its size. When clipOrientation is "vertical", clipping occurs at the top of the drawable.
* bottom 放置对象在它的容器的底部,不改变它的大小。当clipOrientation为"vertical"时,剪裁发生在可绘画对象的顶部。
* left Put the object at the left edge of its container, not changing its size. This is the default. When clipOrientation is "horizontal", clipping occurs at the right side of the drawable. This is the default.
* left 放置对象在它的容器的左边沿,不改变它的大小。这是默认值。当clipOrientation为"horizontal"时,剪裁发生在可绘画对象的右边。这是默认的。
* right Put the object at the right edge of its container, not changing its size. When clipOrientation is "horizontal", clipping occurs at the left side of the drawable.
* right 放置对象在容器的右边沿,不改变它的大小。当clipOrientation是"horizontal"时,剪裁发生在可绘画对象的左边。
* center_vertical Place object in the vertical center of its container, not changing its size. Clipping behaves the same as when gravity is "center".
* center_vertical 放置对象在它的容器的垂直正中,不改变它的大小。剪裁的行为与当重力为"center"时的相同。
* fill_vertical Grow the vertical size of the object if needed so it completely fills its container. When clipOrientation is "vertical", no clipping occurs because the drawable fills the vertical space (unless the drawable level is 0, in which case it's not visible).
* fill_vertical 如果需要的话增加对象的垂直大小,使它完全地填充它的容器。当clipOrientation为"vertical"时,没有剪裁发生,因为可绘画对象填充垂直的空间(除非可绘画对象的级别为0,这种情况下它不可见)。
* center_horizontal Place object in the horizontal center of its container, not changing its size. Clipping behaves the same as when gravity is "center".
* center_horizontal 放置对象在它的容器的水平正中,不改变它的大小。剪裁行为和当重力为"center"时的相同。
* fill_horizontal Grow the horizontal size of the object if needed so it completely fills its container. When clipOrientation is "horizontal", no clipping occurs because the drawable fills the horizontal space (unless the drawable level is 0, in which case it's not visible).
* fill_horizontal 如果需要的话增加对象的水平大小,使它完全填充它的容器。当clipOrientation为"horizontal"时,没有剪裁发生,因为可绘画对象填充水平空间(除非可绘画对象级别为0,这种情况下它不可见)。
* center Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. When clipOrientation is "horizontal", clipping occurs on the left and right. When clipOrientation is "vertical", clipping occurs on the top and bottom.
* center 放置对象在它的容器的垂直和水平方向的正中,不改变它的大小。当clipOrientation为"horizontal"时,剪裁发生在左和右。当clipOrientation为"vertical"时,剪裁发生在上和下。
* fill Grow the horizontal and vertical size of the object if needed so it completely fills its container. No clipping occurs because the drawable fills the horizontal and vertical space (unless the drawable level is 0, in which case it's not visible).
* fill 如果需要的话增加对象的水平和垂直大小,使它完全填充它的容器。没有剪裁发生,因为可绘画对象填充水平和垂直空间(除非可绘画对象的级别为0,这种情况下它不可见)。
* clip_vertical Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
* clip_vertical 额外选项,可以被设置,让子对象的上和/或下边沿被剪裁到它的容器的范围。剪裁基于垂直的重力:上重力剪裁下边沿,下重力剪裁上边沿,两者都不是则都剪裁两个边沿。
* clip_horizontal Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.
* clip_horizontal 额外选项,可以被设置,让子对象的左和/或右边沿被剪裁到它的容器的范围。剪裁基于水平的重力:左重力剪裁右边沿,右重力剪裁左边沿,两者都不是则都剪裁两个边沿。
-------------------------------
* example:
* 示例:
XML file saved at res/drawable/clip.xml:
保存为res/drawable/clip.xml的XML文件:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/android"
android:clipOrientation="horizontal"
android:gravity="left" />
</clip>
-------------------------------
The following layout XML applies the clip drawable to a View:
以下布局XML把剪裁可绘画对象应用到一个View:
-------------------------------
<ImageView
android:id="@+id/image"
android:background="@drawable/clip"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
-------------------------------
The following code gets the drawable and increases the amount of clipping in order to progressively reveal the image:
以下代码获取可绘画对象并增加剪裁的数量以逐步展开图片:
-------------------------------
ImageView imageview = (ImageView) findViewById(R.id.image);
ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();
drawable.setLevel(drawable.getLevel() + 1000);
-------------------------------
Increasing the level reduces the amount of clipping and slowly reveals the image. Here it is at a level of 7000:
级别的增加降低剪裁的数量并且缓慢地展开图片。这里它正处于级别7000:
(图略:
机器人,没有了右边
)
-------------------------------
Note: The default level is 0, which is fully clipped so the image is not visible. When the level is 10,000, the image is not clipped and completely visible.
注意:默认级别为0,它被完全剪裁,使图片不可见。当级别为10,000时,图片不被剪裁并且完全可见。
-------------------------------
* see also:
* 另见:
* ClipDrawable
-------------------------------
Scale Drawable
缩放可绘画对象
A drawable defined in XML that changes the size of another drawable based on its current level.
一个定义在XML中的可绘画对象,它改变另一个可绘画对象的大小,基于它当前的级别。
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a ScaleDrawable.
指向一个ScaleDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/drawable_resource"
android:scaleGravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"]
android:scaleHeight="percentage"
android:scaleWidth="percentage" />
-------------------------------
* elements:
* 元素:
* <scale>
Defines the scale drawable. This must be the root element.
定义缩放可绘画对象。它必须是根元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"。
* android:drawable
Drawable resource. Required. Reference to a drawable resource.
可绘画对象资源。必需的。指向可绘画资源的引用。
* android:scaleGravity
Keyword. Specifies the gravity position after scaling.
关键词。在缩放后指定重力位置。
Must be one or more (separated by '|') of the following constant values:
必须是以下常量值中的一个或多个(用'|'分隔):
-------------------------------
* Value Description
* 值 描述
* top Put the object at the top of its container, not changing its size.
* top 放置对象在它的容器的顶部,不改变它的大小
* bottom Put the object at the bottom of its container, not changing its size.
* bottom 放置对象在它的容器底部,不改变它的大小。
* left Put the object at the left edge of its container, not changing its size. This is the default.
* left 放置对象在它的容器左边沿,不改变它的大小。这是默认值。
* right Put the object at the right edge of its container, not changing its size.
* right 放置对象在它的容器右边沿,不改变它的大小。
* center_vertical Place object in the vertical center of its container, not changing its size.
* center_vertical 放置对象在它的容器的垂直居中,不改变它的大小。
* fill_vertical Grow the vertical size of the object if needed so it completely fills its container.
* fill_vertical 如果需要的话增加对象的垂直大小,使它完全填充它的容器。
* center_horizontal Place object in the horizontal center of its container, not changing its size.
* center_horizontal 放置对象在它的容器的水平居中,不改变它的大小。
* fill_horizontal Grow the horizontal size of the object if needed so it completely fills its container.
* fill_vertical 如果需要的话增加对象的水平大小,使它完全填充它的容器。
* center Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
* center 把对象放置在它的容器的垂直和水平轴方向上的中间,不改变它的大小。
* fill Grow the horizontal and vertical size of the object if needed so it completely fills its container.
* fill 如果需要的话增加对象的水平和垂直大小,使它完全填充它的容器。它是默认的。
* clip_vertical Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
* clip_vertical 额外选项,可以设置它,让子对象的上和/或下边沿剪裁为它的容器的范围。剪裁基于垂直重力:上重力剪裁下边沿,下重力剪裁上边沿,而两者都不是则剪裁两个边沿。
* clip_horizontal Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.
* clip_horizontal 额外选项,可以设置它,让子对象的左和/或右边沿剪裁为它的容器的范围。剪裁基于垂直重力:左重力剪裁右边沿,右重力剪裁左边沿,而两者都不是则剪裁两个边沿。
-------------------------------
* android:scaleHeight
Percentage. The scale height, expressed as a percentage of the drawable's bound. The value's format is XX%. For instance: 100%, 12.5%, etc.
百分比。缩放高度,表达为可绘画对象范围的百分比。值的格式为XX%。例如:100%,12.5%,等等。
* android:scaleWidth
Percentage. The scale width, expressed as a percentage of the drawable's bound. The value's format is XX%. For instance: 100%, 12.5%, etc.
百分比。缩放宽度,表达为可绘画对象范围的百分比。值的格式为XX%。例如:100%,12.5%,等等。
* example:
* 示例:
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/logo"
android:scaleGravity="center_vertical|center_horizontal"
android:scaleHeight="80%"
android:scaleWidth="80%" />
-------------------------------
* see also:
* 另见:
* ScaleDrawable
-------------------------------
Shape Drawable
形状可绘画对象
This is a generic shape defined in XML.
这是定义在XML中的通用形状
* file location:
* 文件位置:
res/drawable/filename.xml
res/drawable/<文件名>.xml
The filename is used as the resource ID.
文件名被用作资源ID。
* compiled resource datatype:
* 被编译的资源数据类型:
Resource pointer to a GradientDrawable.
指向一个GradientDrawable的资源指针。
* resource reference:
* 资源引用:
In Java: R.drawable.filename
在Java中:R.drawable.<文件名>
In XML: @[package:]drawable/filename
在XML中:@[<包名>:]drawable/<文件名>
* syntax:
* 语法:
-------------------------------
<?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>
-------------------------------
* elements:
* 元素:
* <shape>
The shape drawable. This must be the root element.
形状可绘画对象。它必须是根元素。
* attributes:
* 属性:
* xmlns:android
String. Required. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
字符串。必需的。定义XML名字空间,必须是"http://schemas.android.com/apk/res/android"
* android:shape
Keyword. Defines the type of shape. Valid values are:
关键词。定义形状的类型。可用的值有:
-------------------------------
* Value Desciption
* 值 描述
* "rectangle" A rectangle that fills the containing View. This is the default shape.
* "rectangle" 一个矩形,填充包含的View。这是默认形状。
* "oval" An oval shape that fits the dimensions of the containing View.
* "oval" 一个椭圆形状,适应包含的View的尺寸。
* "line" A horizontal line that spans the width of the containing View. This shape requires the <stroke> element to define the width of the line.
* "line" 一个水平线,它跨越所包含的View的宽度。该形状需要<stroke>元素以定义线条的宽度。
* "ring" A ring shape.
* "ring" 一个环形状。
-------------------------------
The following attributes are used only when android:shape="ring":
当android:shape="ring"时使用以下属性:
* android:innerRadius
Dimension. The radius for the inner part of the ring (the hole in the middle), as a dimension value or dimension resource.
尺寸。环的内部部分的半径(中间的洞),作为一个尺寸值或尺寸资源。
* android:innerRadiusRatio
Float. The radius for the inner part of the ring, expressed as a ratio of the ring's width. For instance, if android:innerRadiusRatio="5", then the inner radius equals the ring's width divided by 5. This value is overridden by android:innerRadius. Default value is 9.
浮点型。环的内部部分的半径,表达为环宽度的比例。例如,如果android:innerRadiusRatio="5",那么内部半径等于环的宽度除于5。这个值被android:innerRadius覆盖。默认值为9。
* android:thickness
Dimension. The thickness of the ring, as a dimension value or dimension resource.
尺寸。环的粗度,作为尺寸值或尺寸资源。
* android:thicknessRatio
Float. The thickness of the ring, expressed as a ratio of the ring's width. For instance, if android:thicknessRatio="2", then the thickness equals the ring's width divided by 2. This value is overridden by android:innerRadius. Default value is 3.
浮点型。环的粗度,表达为环的宽度的比例。例如,如果android:thicknessRatio="2",那么粗度等于环的宽度除于2。这个值被android:innerRadius覆盖。默认值为3。
* android:useLevel
Boolean. "true" if this is used as a LevelListDrawable. This should normally be "false" or your shape may not appear.
布尔型。"true"如果它被用作LevelListDrawable。它通常应该是"false",否则你的形状可能不显示。
* <corners>
Creates rounded corners for the shape. Applies only when the shape is a rectangle.
为形状创建圆角。仅当形状为矩形时才应用。
* attributes:
* 属性:
* android:radius
Dimension. The radius for all corners, as a dimension value or dimension resource. This is overridden for each corner by the following attributes.
尺寸。所有角的半径,作为尺寸值或尺寸资源。每个角的这个值被以下属性覆盖。
* android:topLeftRadius
Dimension. The radius for the top-left corner, as a dimension value or dimension resource.
尺寸。左上角的半径,作为尺寸值或尺寸资源。
* android:topRightRadius
Dimension. The radius for the top-right corner, as a dimension value or dimension resource.
尺寸。右上角的半径,作为尺寸值或尺寸资源。
* android:bottomLeftRadius
Dimension. The radius for the bottom-left corner, as a dimension value or dimension resource.
尺寸。左下角的半径,作为尺寸值或尺寸资源。
* android:bottomRightRadius
Dimension. The radius for the bottom-right corner, as a dimension value or dimension resource.
尺寸。右下角的半径,作为尺寸值或尺寸资源。
-------------------------------
Note: Every corner must (initially) be provided a corner radius greater than 1, or else no corners are rounded. If you want specific corners to not be rounded, a work-around is to use android:radius to set a default corner radius greater than 1, but then override each and every corner with the values you really want, providing zero ("0dp") where you don't want rounded corners.
注意:每个角必须(最开始)被赋予一个大于1的角半径,否则没有角是圆角。如果你希望特定的角不是圆角,一个权宜之计是使用android:radius设置一个默认角半径大于1,但是之后用你实际希望的值覆盖全部的每个角,在你不想要圆角的地方提供零值("0dp")。
-------------------------------
* <gradient>
Specifies a gradient color for the shape.
为形状指定一个渐变颜色。
* attributes:
* 属性:
* android:angle
Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45. Default is 0.
整型。渐变的角度,单位度数。0是从左到右,90是从下到上。它必须是45的倍数。默认为0.
* android:centerX
Float. The relative X-position for the center of the gradient (0 - 1.0).
浮点型。渐变中心的相对X位置(0至1.0)。
* android:centerY
Float. The relative Y-position for the center of the gradient (0 - 1.0).
浮点型。渐变中心的相对Y位置(0至1.0)。
* android:centerColor
Color. Optional color that comes between the start and end colors, as a hexadecimal value or color resource.
颜色。可选颜色,它在开始和结束颜色之间,作为一个十六进制值或颜色资源。
* android:endColor
Color. The ending color, as a hexadecimal value or color resource.
颜色。结束颜色,作为一个十六进制值或颜色资源。
* android:gradientRadius
Float. The radius for the gradient. Only applied when android:type="radial".
浮点型。渐变的半径。仅当android:type="radial"时应用。
* android:startColor
Color. The starting color, as a hexadecimal value or color resource.
颜色。开始颜色,作为一个十六进制值或颜色资源。
* android:type
Keyword. The type of gradient pattern to apply. Valid values are:
关键词。使用的渐变模式。可用的值有:
-------------------------------
* Value Description
* 值 描述
* "linear" A linear gradient. This is the default.
* "linear" 一个线性渐变。它是默认的。
* "radial" A radial gradient. The start color is the center color.
* "radial" 一个辐射渐变。开始的颜色是中心颜色。
* "sweep" A sweeping line gradient.
* "sweep" 一个弧线渐变。
-------------------------------
* android:useLevel
Boolean. "true" if this is used as a LevelListDrawable.
布尔型。"true"如果它被用作一个LevelListDrawable。
* <padding>
Padding to apply to the containing View element (this pads the position of the View content, not the shape).
应用在包含的View元素的内边距(它是对于View内容位置的边距,不是形状)。
* attributes:
* 属性:
* android:left
Dimension. Left padding, as a dimension value or dimension resource.
尺寸。左内边距,作为一个尺寸值或尺寸资源。
* android:top
Dimension. Top padding, as a dimension value or dimension resource.
尺寸。上内边距,作为一个尺寸值或尺寸资源。
* android:right
Dimension. Right padding, as a dimension value or dimension resource.
尺寸。右内边距,作为一个尺寸值或尺寸资源。
* android:bottom
Dimension. Bottom padding, as a dimension value or dimension resource.
尺寸。下内边距,作为一个尺寸值或尺寸资源。
* <size>
The size of the shape.
形状的大小。
* attributes:
* 属性:
* android:height
Dimension. The height of the shape, as a dimension value or dimension resource.
尺寸。形状高度,作为一个尺寸值或尺寸资源。
* android:width
Dimension. The width of the shape, as a dimension value or dimension resource.
尺寸。形状宽度,作为一个尺寸值或尺寸资源。
-------------------------------
Note: The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an ImageView, you can restrict scaling by setting the android:scaleType to "center".
注意:默认下,形状按照这里定义的尺寸比例缩放到容器View的大小。当你在一个ImageView内使用形状,你可以通过设置android:scaleType为"center"来限制缩放。
-------------------------------
* <solid>
A solid color to fill the shape.
一个实颜色以填充形状。
* attributes:
* 属性:
* android:color
Color. The color to apply to the shape, as a hexadecimal value or color resource.
颜色。应用到形状的颜色,作为一个十六进制值或颜色资源。
* <stroke>
A stroke line for the shape.
用于形状的笔触线条。
* attributes:
* 属性:
* android:width
Dimension. The thickness of the line, as a dimension value or dimension resource.
尺寸。线条的粗度,作为一个尺寸值或尺寸资源。
* android:color
Color. The color of the line, as a hexadecimal value or color resource.
颜色。线条的颜色。作为一个十六进制值或颜色资源。
* android:dashGap
Dimension. The distance between line dashes, as a dimension value or dimension resource. Only valid if android:dashWidth is set.
尺寸。线条虚线之间的距离,作为尺寸值或尺寸资源。仅当android:dashWidth被设置时才可用。
* android:dashWidth
Dimension. The size of each dash line, as a dimension value or dimension resource. Only valid if android:dashGap is set.
尺寸。每个虚线条的大小,作为一个尺寸值或尺寸资源。仅当android:dashGap被设置时才可用。
* example:
* 示例:
XML file saved at res/drawable/gradient_box.xml:
保存为res/drawable/gradient_box.xml的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:
这个布局XML把形状可绘画对象应用到一个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:
这段应用程序代码获取形状可绘画对象并把它应用到一个View:
-------------------------------
Resources res = getResources();
Drawable shape = res. getDrawable(R.drawable.gradient_box);
TextView tv = (TextView)findViewByID(R.id.textview);
tv.setBackground(shape);
-------------------------------
* see also:
* 另见:
* ShapeDrawable
Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.
除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。
Android 4.0 r1 - 13 Jan 2012 0:46
-------------------------------
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)
(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:
* ソフトウェア技術ドキュメントを勝手に翻訳
http://www.techdoctranslator.com/android
* Ley's Blog
http://leybreeze.com/blog/
* 农民伯伯
http://www.cnblogs.com/over140/
* Android中文翻译组
http://androidbox.sinaapp.com/
)
发表评论
-
【翻译】(9-补丁2)电话簿提供者
2012-07-18 12:54 2400【翻译】(9-补丁2)电话簿提供者 see h ... -
【翻译】(8-补丁1)Android接口定义语言(AIDL)
2012-07-02 05:55 2927【翻译】(8-补丁1)Andro ... -
【翻译】(0)应用组件
2012-06-30 23:50 829【翻译】(0)应用组件 see http:// ... -
【翻译】(88)传感器
2012-05-21 21:25 1078【翻译】(88)传感器 ... -
【翻译】(87)复制与粘贴
2012-05-20 14:48 1929【翻译】(87)复制与粘贴 see http: ... -
【翻译】(86)音频捕捉
2012-05-16 15:14 1104【翻译】(86)音频捕捉 ... -
【翻译】(85)照相机
2012-05-13 15:09 3796【翻译】(85)照相机 see http:// ... -
【翻译】(84)JetPlayer
2012-04-21 16:24 981【翻译】(84)JetPlayer see h ... -
【翻译】(83)媒体回放
2012-04-21 16:00 1860【翻译】(83)媒体回放 see http:/ ... -
【翻译】(82)多媒体与照相机
2012-04-18 23:05 953【翻译】(82)多媒体与照相机 see htt ... -
【翻译】(23-补丁3)构建无障碍服务
2012-04-18 21:57 1627【翻译】(23-补丁3)构 ... -
【翻译】(23-补丁2)使应用程序无障碍
2012-04-16 13:08 2099【翻译】(23-补丁2)使应用程序无障碍 see ... -
【翻译】(23-补丁1)无障碍
2012-04-11 22:38 911【翻译】(23-补丁1)无 ... -
【翻译】(81)Renderscript之运行时API参考手册
2012-04-11 22:13 1416【翻译】(81)Renderscript之运行时API参 ... -
【翻译】(80)Renderscript之计算
2012-04-09 14:09 1444【翻译】(80)Renderscript之计算 ... -
【翻译】(79)Renderscript之图形
2012-04-08 13:59 2866【翻译】(79)Renderscript之图形 ... -
【翻译】(78)Renderscript
2012-04-04 15:35 1442【翻译】(78)Renderscript see ... -
【翻译】(77)可绘画对象动画
2012-03-18 10:52 711【翻译】(77)可绘画对象动画 see htt ... -
【翻译】(76)视图动画
2012-03-18 10:04 806【翻译】(76)视图动画 see http:/ ... -
【翻译】(75)属性动画
2012-03-17 18:24 2508【翻译】(75)属性动画 see http:/ ...
相关推荐
例子6是一个双线程绘画程序,左右手分别画圆和方,通过获取Graphics对象进行绘图,展示了线程如何在图形界面上协同工作。 Java中的线程状态包括新建、就绪、运行、阻塞和死亡。线程调度器根据线程的优先级和“先进...
2. **Gui模块**:提供了构建图形用户界面的基本元素,如窗口(QWindow)、控件(QPushButton、QLineEdit、QLabel等)、布局管理(QLayout)以及绘画API(QPainter)。 3. **Widgets模块**:基于Core和Gui模块,提供...
3. **绘图引擎增强**:CS5引入了新的绘画引擎,提升了画笔的响应速度和真实感,让数字绘画体验接近于传统绘画。 4. **HDR(高动态范围)图像处理**:改进的HDR Pro功能允许用户合并不同曝光的图像,创建具有丰富...
汉化补丁的工作原理通常是将软件原有的英文资源文件替换为翻译后的中文资源文件,包括菜单、对话框、提示信息等,确保软件的所有文字元素都能显示为中文。对于Photoshop CS2而言,这意味着用户可以更直观地找到并...
- **QGraphicsScene/QGraphicsView:** 构建可缩放和可移动的图形视图。 - **QGraphicsItem:** 图形视图中的基础项。 5. **网络编程实现**: - **QTcpSocket/QHttp/QNetworkAccessManager:** 支持TCP/IP和...
文徽明,明代著名的书画家,其作品与人格魅力一同流传至今,成为后人学习与欣赏的对象。他的诗作《绝句》,以简洁的语言表达了其对学问与生活的态度,即不以物质贫富论英雄,唯读书声为佳。这首诗被翻译为拼音版本,...
这很可能是汉化资源文件夹,包含了Photoshop CS6所有界面元素的中文翻译,包括菜单、工具提示、对话框等。在安装过程中,这些文件会被整合到Photoshop的程序文件中,使得软件界面变为中文显示。 Photoshop CS6作为...
NEAT 开 发 指南 文档 适用于 PT80 系列 移动数据终端 版本记录 版本号 版本描述 发布日期 V 1.0 初始版本。 2012-04-12 V1.1 修改前三章内容 2012-09-25 目录 第一章 关于本手册.....................................
"Photoshop CS5英文中文语言包"是专门为Adobe Photoshop CS5版本设计的一种语言资源包,它使得用户可以根据自己的语言需求在英文界面和中文界面之间切换,极大地便利了不同语言背景的用户使用。 语言包通常包含软件...
华山虽然在历史上不如泰山那样频繁地成为帝王朝拜的对象,但它以其险峻的山路和丰富的药用植物而闻名。自上世纪90年代,华山安装了缆车,游客数量逐渐增多,这座历史上的“隐士”逐渐走入了大众的视野。 泰山,作为...
在事件处理方面,书中详细讲解了Qt的信号与槽机制,这是Qt的核心特性,允许对象间进行通信和数据交换。此外,还会介绍如何自定义事件处理器和事件过滤器,以实现更为复杂的应用逻辑。 在网络编程部分,读者将学习...
而在WM_DESTROY消息中,可能需要清理资源,如释放内存分配的对象。 在实际的代码实现中,可能会包含以下几个部分: 1. 注册窗口类(RegisterClassEx):定义窗口类的样式、图标等属性。 2. 创建窗口...
2. **QGui模块**:提供了基本的图形用户界面功能,如事件处理、绘画和图形对象。 3. **QApplication**:每个Qt程序都始于一个QApplication实例,它管理应用程序的生命周期和事件循环。 4. **QObject**:Qt的所有类都...
- **AI绘画设计**:通过算法模拟不同风格的艺术作品,辅助艺术家创作出独特且富有表现力的作品。 #### 六、AI编程工具 AI编程工具旨在简化软件开发过程,提升代码质量和开发效率。 - **AI辅助编程**:提供代码...
这款软件在1984年由Bill Atkinson和Jeffrey Zeldman开发,是苹果系统中的一个标志性应用,它为用户提供了基本的绘画和图像编辑功能,是当时个人计算机艺术创作的先锋。 描述中提到的“麦克漆”是对MacPaint的中文...
"准时制做的日产运河项目"这部分可能是一个翻译错误,实际上可能是指这个项目是按照计划或规定的时间完成的,而"日产运河"可能是误译,可能原意是某种编程练习或者挑战。"Tabuada gerada COM JS"明确了这个乘法表是...