相关疑难解决方法(0)

Picasso v/s Imageloader v/s Fresco vs Glide

发现:

  1. Picasso v/s ImageLoader的区别在这里......
  2. 关于图书馆GLIDE的信息在这里......
  3. 现在最近Facebook发布了名为Fresco的新图像库

问题:

  1. Picasso v/s Imageloader v/s Fresco有什么区别
  2. 我们什么时候可以使用Glide
  3. 哪个是最好的库.
  4. 如果每个图书馆都有自己的意义,那么它们是什么?

android universal-image-loader picasso fresco android-glide

336
推荐指数
6
解决办法
14万
查看次数

Picasso .fit().centerCrop()不使用WRAP_CONTENT

我有一个ImageView以编程方式创建的,并使用Picasso加载图像.ImageView的高度和宽度设置为WRAP_CONTENT.图像非常大,所以我想使用Picasso的.fit().centerCrop()方法来节省内存.但是,当我添加方法时,图像不会显示,我认为它必须是因为WRAP_CONTENT.这是我的代码:

ImageView iv = new ImageView(getContext());
RelativeLayout.LayoutParams centerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
iv.setLayoutParams(centerParams);
Picasso.with(context)load(path).fit().centerCrop().into(iv); //if I remove .fit().centerCrop(), the images load just fine
Run Code Online (Sandbox Code Playgroud)

我能找到的唯一信息是GitHub关于它的这个问题 - 虽然问题说它在v2.4中已经关闭,但有些人评论说他们在v2.5中遇到过它.(我也使用v2.5)

编辑:根据Angela的建议,这就是我现在使用的内容:

ImageView iv = new ImageView(getContext());
RelativeLayout.LayoutParams centerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(350));
centerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
iv.setLayoutParams(centerParams);
iv.setAdjustViewBounds(true);                                    
iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
Picasso.with(getContext()).load(path).fit().into(iv);
Run Code Online (Sandbox Code Playgroud)

现在显示图像,但它们没有正确缩放,宽高比会以某种方式改变.关于如何保持纵横比同时仍允许毕加索进行测量的任何想法.fit()

android android-image android-imageview picasso android-layoutparams

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

Android Picasso"fit().centerCrop()"不加载图片

我想在我使用此代码部分时,根据宽度大小将图像(URL)显示为我的imageview中的最大宽度和可变高度:

imageView = (ImageView) convertView.findViewById(R.id.imageView);
Picasso.with(context).load(product.getImage()).into(imageView);
Run Code Online (Sandbox Code Playgroud)

我可以将我的图像显示到imageview中.我也试过使用resize().centerCrop()方法并且它成功运行.

但是,当我使用时

Picasso.with(上下文).load(product.getImage())拟合()centerCrop()代入(ImageView的).;

要么

Picasso.with(上下文).load(product.getImage())拟合()centerInside()代入(ImageView的).;

我的imageview什么都没显示.我不明白为什么.也许问题是我的列表设计和imageview.这是我的list_content_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:weightSum="1">

    <ImageView 
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.80"
        app:srcCompat="@mipmap/ic_launcher" />

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="1"
        android:layout_weight="0.2"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/tv_title"
            android:layout_width="match_parent"
            android:layout_weight="0.3"
            android:layout_height="match_parent" />
        <TextView
            android:id="@+id/tv_stats"
            android:layout_weight="0.7"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"/>

    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我尝试了将 ImageView的宽度和高度设置为wrap_contentmatch_parent,但它也没有用.我在哪里错过了?提前致谢.

android android-imageview picasso

3
推荐指数
1
解决办法
1896
查看次数