【发布时间】:2016-05-26 13:52:37
【问题描述】:
我在我的应用程序中使用 Glide 从服务器加载图像。图像显示在 ViewPager 中。我面临一个奇怪的问题。首次加载图像时,显示如下:
我不明白为什么会这样。 我已将视图寻呼机高度设置为 140dp。 viewpager 适配器的xml如下:
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:background="@drawable/car_bg"
tools:ignore="ContentDescription" />
从 url 加载图片的代码:
Glide.with(ctx).load(banner.getImgScrollBanner()).placeholder(R.drawable.loading_spinner).error(R.drawable.car_bg).into(bannerView);
【问题讨论】:
-
试试 scaleType 不确定。
-
尝试删除
android:scaleType="centerInside"并添加一次android:adjustViewBounds="true", -
@ShreeKrishna 尝试过仍然面临同样的问题
-
@Nitish 请参阅here,您可能会觉得有帮助。
-
@ShreeKrishna 如果我在 scale 类型中尝试 fitXY 那么它工作正常。
标签: android imageview image-loading