【问题标题】:Image is stretched vertically while using Glide in Grid View Android在 Grid View Android 中使用 Glide 时图像被垂直拉伸
【发布时间】:2015-11-01 14:19:04
【问题描述】:

我制作了一个应用程序,可以在网格视图中显示本地存储的图像。我曾经使用毕加索,但由于许多问题我停止使用它(它没有在某些设备上加载图像)。然后我切换到滑翔,一切很好,只是图像被垂直拉伸。这会导致滚动问题。我在使用毕加索时从未遇到过这样的问题。我该如何解决这个问题?

我的 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>

问题截图-See the image on the right it is stretched vertically

【问题讨论】:

    标签: android android-activity android-gridview android-glide


    【解决方案1】:

    我刚发现。 这是因为占位符图像的大小与原始图像不匹配。

    我的解决方案只是删除占位符或调整占位符的大小

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-17
      • 1970-01-01
      相关资源
      最近更新 更多