Android 如何在imageview中避免图像拉伸
我有一个320x480的映像,我正在320x480设备中运行应用程序。我将图像设置为Android 如何在imageview中避免图像拉伸,android,Android,我有一个320x480的映像,我正在320x480设备中运行应用程序。我将图像设置为android:background,然后我的图像被拉伸。但是如果我使用android:src,那么我会在图像后面留下空白,就好像图像没有覆盖屏幕一样。如何在图像视图中设置图像,使我的图像既不会被拉伸,也不会覆盖整个屏幕 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.a
android:background
,然后我的图像被拉伸。但是如果我使用android:src,那么我会在图像后面留下空白,就好像图像没有覆盖屏幕一样。如何在图像视图中设置图像,使我的图像既不会被拉伸,也不会覆盖整个屏幕
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
>
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/about1"/>
</LinearLayout>
为什么不将图像设置为线性布局的背景?
如果您确实想使用ImageView,您应该为布局高度和布局宽度指定“填充父对象”。您必须提供图像的高度和宽度,就像您有320*480的图像一样,您在声明图像时在xml中提到此尺寸,并将图像存储在(可绘制mdpi)中文件夹,然后运行它。查看ImageView属性 在类似的情况下,将其设置为真对我有帮助@Deepakkk 我想你们已经将图像存储在hdpi或ldpi中,用于高密度或低密度 对于大小为320*480的emulator,您应该将源映像存储在mdpi中 更改图像的高度以填充父对象 试试这个
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
...
</manifest>
...
如果你是,不要隐藏否决投票背后的原因。这将有助于其他人了解下降投票的原因请重新表述问题的最后一部分。试着用要点清楚地说明最终图像应该如何表现。你需要答案还是否决投票的理由?@Raghu,我需要答案以及否决投票的理由。投票失败的原因将帮助我了解自己的局限性,而答案将帮助我摆脱这个问题。我不希望图像被拉伸。我也做了同样的事情。但如果我在Motorolla milestone中测试我的应用程序,这个逻辑就会失败。它从mdpi获取图像。但是它的屏幕尺寸是480x854,你是在用图像来制作平板电脑吗