2017-06-16 51 views
0

我目前刚刚接触Android开发,并且试图让图像按比例缩放以适应不同的屏幕尺寸。我做了一个drawable-hdpi,-mdpi和drawable-xdpi。在这些文件夹中,我放置了图像,但对于每个屏幕密度都有不同的大小(例如,对于xdpi,我将图像放大了)。我将imageView放置在约束布局中,并将高度和重量设置为wrap_content。我期待的图像尺寸与相应的可绘图尺寸相同,但对于更高的屏幕密度,它仍然非常小。有什么想法吗?我还读了大约9个补丁图像,但是我不能在更高密度的可绘制文件夹中添加更大的图像?试图让屏幕变大时ImageView的缩放比例

回答

0

你应该改变的ImageView的scaleType的宽度和高度。 如果你想扩展与保持纵横比的图像,你应该使用

<ImageView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:scaleType="fitcenter"/> 

ü可以尝试像centerCrop和fitxy另一个选项,并查看结果

0
<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scaleType="fitXY" 
     .... 

添加android:scaleType="fitXY"到ImageView的调整来看