0
这个想法是要么显示一张照片,要么 - 如果没有定义 - 一个小图标象征着它。比例图像很好地
我已经在布局中定义了以下的ImageView:
<ImageView
android:id="@+id/imgPic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@+string/strImgPic"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:saveEnabled="false"
android:src="@drawable/pic_icon" />
所以ImageView的是预先初始化为“图标” PNG。
的代码加载它:
try {
imgURL = vinfo.getString("mainpic_url");
if (imgURL.length() > 1) {
imgURL = getString(R.string.urlPicsFull) + imgURL;
ImageView imgPic = (ImageView) findViewById(R.id.imgPic);
ImageDownloader img = new ImageDownloader();
img.download(imgURL, imgPic);
}
} catch (..) {
(..)
ImageDownloader()基本上没有什么比异步检索图像别的。但问题是,如果没有图像(imgURL.length()== 0),图标将在布局中的空方块中间显示一个非常大的“边框”。
我希望将图像缩小(或向上)为父视图的宽度,但图标要显示为原样(大约90度,宽和高)。
有关如何实现这一点的任何建议?
它现在正常工作 - 谢谢! – richey 2012-07-27 05:58:34
很高兴我能帮忙:) – Angelo 2012-07-27 06:47:12