2017-10-14 81 views
-2

我在使用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); 
} 

我已經嘗試了不同的寬度和高度調整大小的方法,但不能夠覆蓋所有的視圖代碼。

+0

你在imageview的設置規模類型? –

+0

[將圖像調整爲使用Picasso的全寬和固定高度]可能的副本(https://stackoverflow.com/questions/20823249/resize-image-to-full-width-and-fixed-height-with-picasso) –

回答

0

我認爲你需要指定的ScaleTypeImageview

嘗試使用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

對於修訂#2,我正在編輯,並沒有看到您的編輯,我沒有看到您的編輯之前,我推動編輯 – Zoe

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! 
+0

當我使用調整大小(70,120).fit()到(背景):有一個錯誤,應用程序崩潰, android監視器fit()不能與resize()一起使用。我正在使用畢加索圖書館2.5.2 –

+0

請參閱此鏈接https://futurestud.io/tutorials/picasso-image-resizing-scaling-andfit –