简体   繁体   English

图像未覆盖应用程序背景的全宽

[英]image is not covering full width of the background of app

I am using an image of size 1080*1920 in my app using picasso library but my image is not covering entire view horizontally.我在我的应用程序中使用 picasso 库使用大小为 1080*1920 的图像,但我的图像没有水平覆盖整个视图。 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.我在调整大小方法中尝试了不同的宽度和高度,但无法覆盖所有视图。

I think you need to specify the ScaleType of your Imageview我认为您需要指定ScaleTypeImageview

Try using fit() :尝试使用fit()

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

or .centerCrop().centerCrop()

 Picasso.with(this).load(R.drawable.background)
        .centerCrop().resize(70,120).centerCrop().into(background);
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!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM