我想将带有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”