处理图片
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在表盘中使用图片可以让表盘更加生动,从全屏背景图片到各个细节图片,都能增添趣味。
将图片资源放入 res/drawable
文件夹(例如 res/drawable/face.png
),然后按如下方式引用图片:
<PartImage x="100" y="100" width="250" height="250">
<Image resource="face"/>
</PartImage>
与表盘格式中的其他容器一样,PartImage
元素可以通过多种方式进行修改,包括缩放、旋转、转换、着色或遮罩。如需了解详情,请参阅 PartImage
参考文档。
更改背景
一种能带来趣味的效果是每小时更改一次背景。您可以通过使用 Images
元素来实现此目的,例如:
<PartImage ...>
<Images change="ON_NEXT_HOUR">
<Image resource="background1"/>
<Image resource="background2"/>
...
</Images>
</PartImage>
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Work with images\n\nUsing images in your watch face can really help bring it to life, from a\nfull-screen background image to individual detail images to add interest.\n\nPlace your image resources in the `res/drawable` folder, for example\n`res/drawable/face.png`, and then reference the image as follows: \n\n \u003cPartImage x=\"100\" y=\"100\" width=\"250\" height=\"250\"\u003e\n \u003cImage resource=\"face\"/\u003e\n \u003c/PartImage\u003e\n\nThe `PartImage` element, as with other containers in Watch Face Format,\ncan be modified in\nmany ways, including being scaled, rotated, transformed, tinted, or masked.\nSee the [`PartImage`](/training/wearables/wff/group/part/image/part-image) reference for more information.\n\n### Vary the background\n\nOne effect that can provide interest is to change the background every hour.\nThis can be achieved through the use of the `Images` element, for example: \n\n \u003cPartImage ...\u003e\n \u003cImages change=\"ON_NEXT_HOUR\"\u003e\n \u003cImage resource=\"background1\"/\u003e\n \u003cImage resource=\"background2\"/\u003e\n ...\n \u003c/Images\u003e\n \u003c/PartImage\u003e"]]