使用URL将图像加载到底部导航栏项目图标中
我正在尝试使用firebase存储URL加载配置文件图像,其中包括我的代码:
Glide.with(getApplicationContext()).asBitmap().load(profilePicUrl)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Drawable profileImage = new BitmapDrawable(getResources(), resource);
bottomNav.getMenu().getItem(4).setIcon(profileImage);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
profilepicurl
确实有效,我已经将其用于其他图像视图。但是,当我运行应用程序时,图标的尺寸会更改与我要加载的图片相对应,但是里面没有图像,这是它的外观。
I'm trying to load a profile image using the firebase storage url inside an item's icon of a bottom navigation bar, here's my code:
Glide.with(getApplicationContext()).asBitmap().load(profilePicUrl)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Drawable profileImage = new BitmapDrawable(getResources(), resource);
bottomNav.getMenu().getItem(4).setIcon(profileImage);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
The profilePicUrl
does work, I already use it to for another image view. However when I run the app, the dimensions of the icon changes corresponding to the picture that I'm trying to load but there's no image inside, here's how it looks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
菜单不支持彩色图像
图像,也无法使用更多:
您不能在这些地方使用彩色 对于其资源,无法具有彩色图像。这就是为什么您看不到它。要自己测试,请在可绘制的可绘制中拍摄彩色图像,并将其设置为底部导航的图标。您会注意到它以相同的方式出现。这证明了它
编辑
Menus do not support coloured images
You can not use a coloured image in these places and a bit more also:
Basically which ever view uses a menu file for its resource, cannot have a coloured image. That is why you don't see it. To test it yourself, take a colourful image in your drawable and set it as an icon for the bottom navigation. You notice that it comes the same way. This proves it
Edits