网络上下载下来的图片自适应:
android:adjustViewBounds="true"(其详细解释在下面)
<ImageView
<ImageView
android:id="@+id/dynamic_item_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="5dip"
android:adjustViewBounds="true"
android:background="@drawable/imageview_background" />
另外,android:background="@drawable/imageview_background"是给图片加了一个边框,其中
imageview_background.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/white"/> <stroke android:width="2.0dip" android:color="#99D9D9D9" /> <corners android:radius="2.0dip" /> <padding android:left="5.0dip" android:top="5.0dip" android:right="5.0dip" android:bottom="5.0dip" /> </shape>
ImageView属性说明:
1、类概述
显示任意图像,例如图标。ImageView类可以加载各种来源的图片(如资源或图片库),需要计算图像的尺寸,比便它可以在其他布局中使用,并提供例如缩放和着色(渲染)各种显示选项。
2、XML属性
原文地址: http://blog.sina.com.cn/s/blog_618199e60100y537.html