将文件从 photoshop 导出到 android studio

Export files from photoshop to android studio

我正在使用 photoshop 创建一个图形,我想在任何设备类型上跨越整个屏幕宽度。然而,下面的影响是我得到的。我将原始文件导出为 320x480 然后按 1.5、2.0、3.0 和 4.0 缩放图像。如何获得可缩放并横跨整个屏幕宽度的图形?

使用ImageView#ScaleType

Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). The image is then centered in the view. From XML, use this syntax: android:scaleType="centerCrop".

<ImageView
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:src="@drawable/create_account"
    android:scaleType="centerCrop" />

使用此代码

android:scaleType="fitXY" 这会使图像拉伸或适合图像视图的整个宽度和高度

如果图像是水平的(你的情况)它会拉伸图像,这看起来不太好所以尝试使用垂直图像

当图像是垂直的时候效果很好

<ImageView 
   android:id="@+id/imageView" 
   android:layout_height="match_parent"
   android:layout_width="match_parent"
   android:src="@drawable/img"
   android:scaleType="fitXY"/>

如果你想让图片居中然后使用这个

android:scaleType="centerCrop"

这将使图像居中