android - 使用滑行动态加载图片到 ActionBar
问题描述
我想将图像加载Glide
到我的ImageView
那个是ActionLayout
这是我的菜单项
<item
android:id="@+id/menu"
android:title="Menu"
app:actionLayout="@layout/menu_action_layout"
app:showAsAction="always" />
这是我的动作布局
<ImageView
android:id="@+id/profileImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="20dp" />
</FrameLayout>
这就是我加载它的方式
override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu)
val menuItem = menu.findItem(R.id.menu)
val rootView = menuItem.actionView
val profileImageView = rootView.findViewById<ImageView>(R.id.profileImageView)
val url = "https://www.dropbox.com/s/vauhd1q4nhoz7pn/ronaldo_profile.jpg?dl=1"
Glide.with(this)
.load(url)
.into(profileImageView)
}
不幸的是,它不会加载图像。我已经尝试过使用普通的drawable并且它有效。
解决方案
您无法从 Dropbox 加载图像,您需要将“https://www.dropbox.com”更改为“ https://dl.dropboxusercontent.com ”,这样您的网址将如下所示:“ https:// dl.dropboxusercontent.com/s/vauhd1q4nhoz7pn/ronaldo_profile.jpg "
推荐阅读
- mobile - 有人可以帮助我使用移动应用程序的 XPages DataView 控件吗?
- excel - 尝试根据第一列删除重复项
- r - RMarkdown - 第二个内联代码显示代码块而不是值
- javascript - \PlaylistItems:list API 在删除视频时返回少于 totalResults
- google-cloud-firestore - 在 Flutter 应用程序中包含 Firestore 的问题
- django - Django ORM 验证数据库中的一行
- hive - Kafka 到 Flink 到 Hive - 写入失败
- ansible - 在 Ansible Jinja2 模板的默认过滤器中使用变量
- ios - 在 UIButton 的边缘动态对齐图像
- flutter - 使用构建器构建时如何访问列表项?