我制作了一个应用程序,可以在 GridView 中显示本地存储的图像。我曾经使用 Picasso,但由于许多问题(它没有在某些设备上加载图像)而停止使用它。然后我切换到 glide,一切很好,除了图像被垂直拉伸(stretch)。这会导致滚动问题。我在使用 Picasso 时从未遇到过这样的问题。我该如何解决这个问题???
我的 MainActivity 代码-
Glide.with(MainActivity.this)
.load(mThumbIds[position])
.placeholder(R.raw.place_holder)
.error(R.raw.big_problem)
.centerCrop()
.into(imageView);
return imageView;
我的activity_main.xml文件代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:columnWidth="150dp"
android:numColumns="2"
android:layout_above="@+id/adView" />
<com.google.android.gms.ads.AdView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/adView"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
最佳答案
我才知道。 这是因为占位符图像的大小与原始图像不匹配。
我的解决方案是简单地删除占位符或调整占位符的大小
关于android - 在 Grid View Android 中使用 Glide 时图像被垂直拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33463147/