标签: android-wear-complication

如何从Android磨损并发症提供商在表盘上绘制图标?

使用Complications API有一个图标类型,但是在绘制图标时我不知道该怎么做.

当我绘制实际的表盘时,似乎没有drawIcon方法.例如像canvas.drawIcon(icon).我只能看到如何绘制位图.

在我的drawComplications方法中我有这个:

} else if (complicationData.getType() == ComplicationData.TYPE_ICON) {
                Icon icon = complicationData.getIcon();
Run Code Online (Sandbox Code Playgroud)

然后我如何将图标绘制到画布?

这里的代码实验室没有告诉我们如何绘制图标:https://codelabs.developers.google.com/codelabs/complications/index.html?index =..% 2F..%2Findex#3

我可以只将所有drawable复制到本地可穿戴模块,并通过传入一个字符串绕过图标​​类型,然后从那里绘制相应的位图.但必须有一种方法可以从图标中提取,否则为什么会这样呢?

我也无法从谷歌搜索中找到如何将图标转换为位图,但这似乎也很愚蠢,因为我不得不首先将位图转换为图标,因为API需要一个图标.

任何帮助赞赏.

谢谢.

android android-wear-data-api android-wear-2.0 android-wear-complication wear-os

4
推荐指数
1
解决办法
511
查看次数

Android Wear模块中的“意外的名称空间前缀“ app””

我根据此Google文档添加了一个新的Android Wear模块

但出现标题中描述的错误。这是我的布局。

<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/dark_grey"
    android:padding="@dimen/box_inset_layout_padding"
    tools:context=".MainWearActivity"
    tools:deviceIds="wear">  

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/inner_frame_layout_padding"
        app:boxedEdges="all">  <---this is the offending line 

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

    </FrameLayout>
</android.support.wear.widget.BoxInsetLayout>
Run Code Online (Sandbox Code Playgroud)

有人知道发生了什么吗?感谢您对我为什么收到此错误的解释。更新:我删除了多余的android前缀。Android Studio要求我更改应用程序前缀以更改为android,但即使这样做,错误仍然存​​在。现在是安全的时间来假设它是一个错误吗?

android android-wear-data-api android-wear-complication

3
推荐指数
1
解决办法
828
查看次数