根据调整屏幕分辨率的Andr​​oid图像图像、根据、屏幕分辨率、Andr

2023-09-05 02:01:27 作者:▍窒息旳鬼魅

予有在主体上的背景图像。 我想实现的是:

I have a background image in body. What I want to achieve is that:

1) - 计算访问者的屏幕分辨率。 2) - 根据该决议我要调整我的背景图片

1) - Calculate the visitor screen resolution. 2) - based on that resolution I want to resize my background image.

我知道拿到的屏幕分辨率为

I know get the screen resolution as a

Display display = getWindowManager().getDefaultDisplay();
width_screen = display.getWidth();
height_screen = display.getHeight();

但我不知道该如何调整,根据用户的屏幕分辨率的图片。

But I don't know how to resize the images according screen resolution of user.

谁能帮助? 谢谢..

Can anyone help? Thanks..

推荐答案

将一个ImageView的布局中的文件,并设置

Put a ImageView in your layout file and set

    android:layout_width="match_parent"
    android:layout_height="match_parent"

如果你想保持方面使用:

If you want to keep the aspect use:

    android:scaleType="centerInside"

如果你不关心的宽高比使用:

If you dont care about the aspect ratio use:

    android:scaleType="fitXY"