I wanted to load image from url into bottomnavigationview's menu item icon. same like instagram we wanted to show profile image in one of our menu which might change while switching from different available profiles. Currently, I am trying below code but it does not load image every time.
val menu = mViewDataBinding?.bnvNavigation?.menu
val menuItem = menu?.findItem(R.id.menu_profile)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
menuItem?.setIconTintList(null)
menuItem?.setIconTintMode(null)
}
Glide.with(this)
.asBitmap()
.load(profilePic)
.apply(
RequestOptions.circleCropTransform()
.placeholder(R.drawable.user_profile_icon_updated)
)
.into(object :
CustomTarget<Bitmap>(UIHelper.dpToPx(this, 24), UIHelper.dpToPx(this, 24)) {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
menuItem?.icon = BitmapDrawable(resources, resource)
}
override fun onLoadCleared(placeholder: Drawable?) {
}
})
question from:https://stackoverflow.com/questions/65943088/how-to-load-image-from-url-into-bottomnavigationview-menu-item-icon