-2

I am using an image of size 1080*1920 in my app using picasso library but my image is not covering entire view horizontally. Here is the code for picasso

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

I have tried different width and height in resize method but not able to cover all the view.

AZIM MOHAMAD
  • 72
  • 11

2 Answers2

0

I think you need to specify the ScaleType of your Imageview

Try using fit():

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

or .centerCrop()

 Picasso.with(this).load(R.drawable.background)
        .centerCrop().resize(70,120).centerCrop().into(background);
Zoe stands with Ukraine
  • 25,310
  • 18
  • 114
  • 149
AskNilesh
  • 63,753
  • 16
  • 113
  • 150
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!
Sirisha Ch
  • 21
  • 4
  • when I used resize(70,120).fit().into(background): there is an error, app crashes, error stated by android monitor that fit() can not be used with resize(). I am using picasso library 2.5.2 – AZIM MOHAMAD Oct 14 '17 at 18:49
  • refer this link https://futurestud.io/tutorials/picasso-image-resizing-scaling-and-fit – Sirisha Ch Oct 19 '17 at 11:27