android - 如何在画布上绘制 android.graphics.drawable.Icon?
问题描述
我吓了一跳。我确信 Icon 会表现得像任何其他可绘制对象。但我没有看到任何 draw 或 setBounds 方法。我找不到任何输出图标的示例(其中很多用于从位图创建图标)。如何在特定位置的画布上绘制 android.graphics.drawable.Icon 的东西?
解决方案
您可以使用loadDrawable(Context context)
方法来获取官方文档Drawable
中提到的对象
Returns a Drawable that can be used to draw the image inside this Icon, constructing it if necessary. Depending on the type of image, this may not be something you want to do on the UI thread, so consider using loadDrawableAsync instead.
Context: Context in which to load the drawable; used to access Resources, for example.
Returns : A fresh instance of a drawable
for this image, yours to keep.
推荐阅读
- android - 对来自主线程的 Android Room 调用感到困惑
- javascript - 如何有条件地渲染 Material UI 列表中的选项?
- eclipse - build.gradle - 配置 Eclipse,以便 System.getenv('PATH') 返回与 macOS 命令行中相同的值
- algorithm - 平均成本/算法
- rocket.chat - Rocket.Chat REST API“/api/v1/users.register”没有响应
- c# - 从后面的代码中每次键盘输入后调整 ListView(在 stacklayout 内)的大小
- node.js - Mailgun console.log(body) 返回未定义
- javascript - 如何将字符串转换为日期忽略区域部分?
- php - 如何加快 INNER JOIN MySQL 查询
- flutter - 颤振范围滑块不移动