繁体   English   中英

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

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

我在我的应用程序中使用 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);
}

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

我认为您需要指定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);
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