【问题标题】:Picasso center image without resizing into ImageView毕加索中心图像而不调整到 ImageView
【发布时间】:2015-06-25 21:02:52
【问题描述】:

我遇到了Picasso library 的这个简单问题。我还没有找到任何方法将图像放入ImageView 中心,就像android:ScaleType="center" 一样,无需裁剪。您对如何解决这个问题有任何想法吗?我的问题是我在运行时不知道我下载的BitMap 的高度和宽度,所以我不能正确使用resize()

【问题讨论】:

    标签: android bitmap android-imageview picasso


    【解决方案1】:

    这有点晚了,但对于正在寻找解决方案的人来说:

    Picasso
        .with(context)
        .load(ImageURL)
        .fit()
        // call .centerInside() or .centerCrop() to avoid a stretched image
        .into(imageViewFit);
    

    【讨论】:

    • 嗨,Alok,我实际上正在寻找解决方案,但如果合适,它会调整图像大小。有时,我的图像只有 32x32 像素,我不想调整它的大小。有什么想法吗?
    • 尽量不要使用任何 fit / centerInside / centerCrop 调用。这是官方网站:square.github.io/picasso;如果它不起作用,可能是 xml 中的 imageview scaletype 尝试更改它。
    【解决方案2】:

    如果您的ImageView 在一个维度上是固定的而在另一个维度上是灵活的(例如android:width="match_parent"android:height="wrap_content"),您应该能够使用android:adjustViewBounds="true" 来让ImageView 调整大小以显示您的图像,而无需裁剪。

    【讨论】:

    • 好的,但这并不能解决我的问题。我正在将大量图像下载到内部带有 imageView 的 pagerview 中。所以我需要调整照片的大小以避免内存问题
    【解决方案3】:

    如果不调整大小,我不适合居中,

     Picasso.get()
                            .load(source).resize(1650,700)
                            .centerCrop(Gravity.CENTER).into(imageView, new Callback() 
    

    【讨论】:

      猜你喜欢
      • 2019-07-15
      • 1970-01-01
      • 2020-05-02
      • 2021-08-09
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 2021-06-09
      相关资源
      最近更新 更多