1

我对 Android 中 ImageView 中的图片有疑问。

我的问题是,我想在 ImageView 中显示的图片对于我的智能手机屏幕来说似乎太大了。因此它不在我在 xml 中设置的位置...

这是一张你知道我的意思的图片:http ://www10.pic-upload.de/31.10.12/iuebxzkvr3e.png 灰色区域是我的横幅,它应该位于我的活动之上......如果我缩放图片,它应该可以工作(越小,越高直到它适合),但我认为其他分辨率不同的智能手机应该再次与我的应用程序有同样的问题..

这是我的 XML:

<ImageView android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:id="@+id/ivBanner"
               android:src="@drawable/banner"/>

没什么特别的。

提前致谢

4

2 回答 2

0

you can set scaleType for ImageView to fitXY, or centerCrop

android:scaleType = "fitXY"
于 2012-10-31T08:19:04.427 回答
0

在您的布局中,您应该将其高度和宽度设置为绝对 dp 值:

这是一个 px 到 dp 的转换器:

http://labs.skinkers.com/content/android_dp_px_calculator/

这解决了我的问题,对于每个屏幕尺寸,您需要不同的值(hdpi/xhdpi)。

于 2012-10-31T08:22:30.447 回答