【问题标题】:Image won`t fit screen图片不适合屏幕
【发布时间】:2010-03-25 12:29:32
【问题描述】:

我有一张 320x480 的图片,我希望它适合整个屏幕。这是main.xml代码

<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

任何帮助将不胜感激。

【问题讨论】:

  • 感谢您的回答,但我只是通过使用 LinearLayout 并将图像设置为背景来修复它。我不知道这是否是正确的方法。 schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/wallpaper320x480">
  • 正确的方法取决于您想要实现的目标以及您希望它如何在具有不同屏幕尺寸和不同纵横比的机器人上发挥作用......这取决于。

标签: android imageview


【解决方案1】:

这可能是图片大小和缩放不足的问题。如果您的图片没有足够的像素来填充屏幕并且您没有告诉它拉伸图片,那么您将在两侧有间隙。解决方法是使用android:scaleType="fitXY"。请注意,这适用于使用android:src="..." 而不是android:background="..." 设置图像的情况,因为默认情况下背景设置为拉伸并适合视图。 (两者兼有的目的是让您可以通过将框架设置为背景并将主图像设置为源来执行诸如在图像周围设置框架之类的操作。)

【讨论】:

  • 我的背景也有同样的问题。在手机中查看时看起来还不错。但从我的 XOOM 中查看时,它不会占用整个 Layout(图像设置为背景)。
猜你喜欢
  • 2018-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-07
  • 2016-05-25
相关资源
最近更新 更多