所以,我认为应该显示的任意图像,从网上下载资料图片的ImageView的。我想这个ImageView的扩展自己的形象,以适应父容器的高度内,并60dip的一组最大宽度。然而,如果图像是高大比的角度来看,并且不需要宽度的完整60dip,所述的ImageView宽度应该减少,以便该视图的背景紧密地配合在图像周围
So, I have an imageview that should display an arbitrary image, a profile picture downloaded from the internet. I want this the ImageView to scale its image to fit inside the height of the parent container, and a set max width of 60dip. However, if the image is tall ratio-wise, and doesn't need the full 60dip of width, the ImageView's width should decrease so the view's background fits snugly around the image.
我想这一点,
<ImageView android:id="@+id/menu_profile_picture"
android:layout_width="wrap_content"
android:maxWidth="60dip"
android:layout_height="fill_parent"
android:layout_marginLeft="2dip"
android:padding="4dip"
android:scaleType="centerInside"
android:background="@drawable/menubar_button"
android:layout_centerVertical="true"/>
但做了ImageView的超大型出于某种原因,也许是使用的图像和WRAP_CONTENT的固有宽度来设置它 - 无论如何,它没有尊重我的属性了maxWidth ..没有,只有在里面工作的一些类型的容器?这是在LinearLayout中...
but that made the ImageView super large for some reason, maybe it used the intrinsic width of the image and wrap_content to set it - anyway, it didn't respect my maxWidth attribute.. Does that only work inside some types of containers? It's in a LinearLayout...
有什么建议?
嗯,
android:adjustViewBounds="true"
时,需要使用maxWidth工作。
is required for maxWidth to work.
现在的作品!