图片未覆盖应用

时间:2017-10-14 10:33:18

标签: android picasso

我使用picasso库在我的应用程序中使用大小为1080 * 1920的图像,但我的图像没有水平覆盖整个视图。这是毕加索的代码

private void initBackgroundImage() {
    ImageView background = (ImageView) findViewById(R.id.iv_background);
    Picasso.with(this).load(R.drawable.background).resize(70,120).centerCrop().into(background);
}

我在调整大小方法中尝试了不同的宽度和高度,但无法覆盖所有视图。

2 个答案:

答案 0 :(得分:0)

我认为您需要指定ScaleType

Imageview

尝试使用fit()

Picasso.with(this).load(R.drawable.background)
        .fit().resize(70,120).centerCrop().into(background);

.centerCrop()

 Picasso.with(this).load(R.drawable.background)
        .centerCrop().resize(70,120).centerCrop().into(background);

答案 1 :(得分:0)

Try using     Picasso.with(this).load(R.drawable.background).resize(70,120).fit().into(background);
or
Picasso.with(this).load(R.drawable.background).resize(70,120).into(background);

Don't use centerCrop() property if you are trying to show full image without cropping. Try using different image styles like centerInside() or fit()

Hope it may works!