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

标签 android imageview

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

相关文章:

android - ClassCastException : android. 支持.v7.widget.ShareActionProvider

java - 所有 Android 版本的 Android 互联网连接

android - 如何让缩略图适合 ImageView ?

Android ImageView - 从 URL 加载图像

java - 优雅地处理异常

android - 在 Android 中为微调器设置多个值

android - 如何在编译期间强制 "./configure"停止使用 -pthread?

java - 带有俄语网址的 ImageView

android - 为 ImageView 实现 GestureDetector

ios - UITableView 中的单元格 imageView 在被选中之前不会出现