简体   繁体   English

如何在Wear OS的表面中使用视图?

[英]How can I use Views in a Watchface for Wear OS?

When I want to insert a view in my watchface (class: CanvasWatchFaceService), findViewById is not resolved. 当我想在自己的表面上插入视图时(类:CanvasWatchFaceService),findViewById无法解析。 I need it for AnimatedDrawable. 我需要AnimatedDrawable。

I wrote a blog post on the subject a few years back: Layout-based Watch Faces for Android Wear . 几年前,我写了一篇有关该主题的博客文章: Android Wear的基于布局的表盘 Because it was written in 2015, a few details have changed - like the name of the OS, and steps for creating the initial project in Android Studio - but the general approach still works. 因为它是2015年编写的,所以一些细节已经更改-例如操作系统的名称,以及在Android Studio中创建初始项目的步骤-但一般方法仍然有效。

Also, here's a more recent sample where I used the technique specifically for animations: https://github.com/StringMon/io18watchface 另外,这是我使用的专门用于动画的技术的最新示例: https : //github.com/StringMon/io18watchface

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM