机器人:在ImageView的,以适合屏幕拉伸图像机器人、图像、屏幕、适合

2023-09-12 08:32:39 作者:不负相思意

我有有它的高度和宽度设置为FILL_PARENT与LinearLayout中具有同一值的ImageView的。所以,我想这应该设置我的图片以适应屏幕。但它只适合像80%(保证金顶部和底部在横向模式下)。

I have an imageview that has its height and width set to "fill_parent" with a linearlayout that has the same values set. So i suppose this should set my images to fit the screen. But it only fits like 80% (margin top and bottom in landscape mode).

所以,香港专业教育学院尝试了以下code,但没有成功:

So ive tried the following code, without success:

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

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

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

任何其他的想法?

Any other ideas?

推荐答案

使用 imgview.setScaleType(ScaleType.FIT_XY);