小编Yas*_*ine的帖子

使用 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) {

        }
    });
Run Code Online (Sandbox Code Playgroud)

profilePicUrl确实有效,我已经将它用于另一个图像视图。但是,当我运行该应用程序时,图标的尺寸会根据我尝试加载的图片而变化,但内部没有图像,如下所示

java android android-glide bottom-navigation-bar

5
推荐指数
1
解决办法
858
查看次数