我有一个 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/