gpt4 book ai didi

android:在imageview中拉伸(stretch)图像以适应屏幕

转载 作者:IT老高 更新时间:2023-10-28 13:00:15 25 4
gpt4 key购买 nike

我有一个 imageview,它的高度和宽度设置为 fill_parent,而 linearlayout 的值设置相同。所以我想这应该将我的图像设置为适合屏幕。但它只适合 80%(横向模式下的顶部和底部边距)。

我尝试了以下代码但没有成功:

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();

imgView.setMinimumWidth(width);
imgView.setMinimumHeight(height);

imgView.setMaxWidth(width);
imgView.setMaxHeight(height);

还有其他想法吗?

最佳答案

以编程方式更改使用:

imgview.setScaleType(ScaleType.FIT_XY);

从xml改用:

 android:scaleType="fitXY"

关于android:在imageview中拉伸(stretch)图像以适应屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4668001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com