图像不覆盖应用程序背景的全宽
我在使用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);
}
我已经尝试了不同的宽度和高度调整大小的方法,但不能够覆盖所有的视图代码。
我认为你需要指定的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);
对于修订#2,我正在编辑,并没有看到您的编辑,我没有看到您的编辑之前,我推动编辑 – Zoe
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!
当我使用调整大小(70,120).fit()到(背景):有一个错误,应用程序崩溃, android监视器fit()不能与resize()一起使用。我正在使用毕加索图书馆2.5.2 –
请参阅此链接https://futurestud.io/tutorials/picasso-image-resizing-scaling-andfit –
你在imageview的设置规模类型? –
[将图像调整为使用Picasso的全宽和固定高度]可能的副本(https://stackoverflow.com/questions/20823249/resize-image-to-full-width-and-fixed-height-with-picasso) –