android - 在 Xamarin.Android Toolbar.axml 中使用下载的图像
问题描述
为了能够在我的 Xamarin 表单应用程序(在 Android 案例中)的导航标题栏的右侧显示徽标,我在本机 Xamarin.Android 项目的 Toolbar.axml 文件中使用它。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:src="@drawable/xlogo_small"
android:layout_gravity="right"
android:layout_alignParentRight="true" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
在 android:src 中,我使用的是 xlogo_small 图像文件,它需要位于 drawables 文件夹中。现在我希望在运行时将该文件动态地(通过 Web 服务调用)添加到 drawables 文件夹中。经过快速搜索后,我发现在运行时无法将文件添加到可绘制文件夹中。
我还发现,在这种情况下,图像应该保存到内部存储器中。在 Xamarin Forms Shared 项目中,我可以通过 Web 服务调用检索徽标并将其保存到:Environment.SpecialFolder.Personal 目录。
我想知道是否有任何方法可以引用存储在此内部存储目录中的文件的路径,并在 Resources.axml 的这一行中使用它而不是 @drawable/xlogo_small:
android:src="@drawable/xlogo_small"
任何指针?
解决方案
推荐阅读
- javascript - 为什么登录JS控制台时x++不是x+1?
- python - 数据预处理类型错误:'在
' 需要字符串作为左操作数,而不是列表 - fat-free-framework - fat-free-framework 多语言:翻译包含链接的字符串?
- file - 我可以将使用 getUserMedia 收到的值传输到输入文件吗?
- python - 当屏幕上只有 1 个图像时,pyautogui.locateAll() 返回数百个相似位置
- c# - 将授权属性“/Account/Login”更改为自己的登录路径
- java - Spring Boot、JPA、AWS-RDS(PostgreSql)、多模式
- r - 带有 ggplot2 和数据准备的多图图表
- r - 仅当字段存在时重命名,否则忽略
- c# - 如何使用 wpf 在 blazor 上设置 WebView2 设置