从web下载的java图像,用于listview中的行
我有一个lisview,每一行都在自己的xml文件中定义:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="fill_parent"
安卓:layout_height="120dip"
安卓:padding="6dip" >
<ImageView
安卓:id="@+id/icon"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:adjustViewBounds="true"
安卓:duplicateParentState="true"
安卓:scaleType="fitCenter" />
<TextView
安卓:id="@+id/ime"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/icon"
安卓:layout_below="@+id/icon"
安卓:layout_marginTop="19dp"
安卓:text="TextView" />
<TextView
安卓:id="@+id/cena1"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignTop="@+id/icon"
安卓:layout_marginLeft="56dp"
安卓:layout_toRightOf="@+id/ime"
安卓:text="TextView" />
<Button
安卓:id="@+id/gumb_klic"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_above="@+id/ime"
安卓:layout_alignParentRight="true"
安卓:layout_marginLeft="25dip"
安卓:layout_marginRight="5dip"
安卓:layout_marginTop="10dip"
安卓:background="@drawable/call_button"
安卓:focusable="false"
安卓:focusableInTouchMode="false" />
<TextView
安卓:id="@+id/razdalja"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignBaseline="@+id/ime"
安卓:layout_alignBottom="@+id/ime"
安卓:layout_alignLeft="@+id/cena1"
安卓:layout_marginTop="10dip"
安卓:text="TextView" />
<TextView
安卓:id="@+id/cena2"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/cena1"
安卓:layout_centerVertical="true"
安卓:text="TextView" />
</RelativeLayout>
在eclipse布局编辑器中,它如下所示(ok):
要下载每行imageview(@+id/icon)的图像,我使用通用图像加载程序库(https://github.com/nostra13/Android-Universal-Image-Loader)。 问题是,当图像被下载时,它应该更小,而且行也更小。如果我把从参考资料下载的图片放在同一张图片上,在下载完成之前一切都很好,然后图片变小了,行也变小了
我的布局有什么问题吗
# 1 楼答案
乍一看,我认为这是因为您已将scaleType设置为“fitCenter”,并为布局高度定义了一个绝对值。你的图像正在缩放,以适应120度的填充