代码之家  ›  专栏  ›  技术社区  ›  Maragues

图像不适合屏幕

  •  1
  • Maragues  · 技术社区  · 16 年前

    <ImageView   xmlns:android="http://schemas.android.com/apk/res/android">
            android:id='@+id/splash_medium'
    
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
    
            android:src="@drawable/wallpaper320x480"
             />
    

    屏幕上显示的是图像,但左侧和右侧有相当大的填充,顶部和底部有一点填充。我试过将android:padding设置为0dip,但没有结果。

    链接到图像,我还不能发布图像: screenshot

    任何帮助都将不胜感激。

    1 回复  |  直到 16 年前
        1
  •  11
  •   Steve Haley    16 年前

    这可能是你的图片大小和缩放不足的问题。如果你的图片没有足够的像素来填充屏幕,而你又不告诉它去拉伸图片,那么你的两边就会有空隙。解决方法是使用 android:scaleType="fitXY" android:src="..." 而不是 android:background="..." 默认情况下,背景设置为拉伸并适合视图(两者兼备的目的是让您可以通过将帧设置为背景,将主图像设置为源,从而在图像周围创建一个帧。)