我已经按照下面的方式设置了我的ImageView:
<ImageView android:id="@+id/dl_image"
android:layout_width="60dp"
android:background="@drawable/pictureframe"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:scaleType="fitCenter"/>
请注意,layout_width被固定为60dp。根据我在线获取的内容,我希望将此宽度调整为90dp或120dp(同时保持图像的纵横比例)。
我尝试使用setLayoutParams,但是传递LayoutParams(120, LayoutParams.WRAP_CONTENT)会抛出异常。它似乎不喜欢它。
如果可能的话,我想避免为更大的尺寸制作另一个ImageView。
ViewGroup
的事情,我已经编辑了答案以反映这一点。 - Peter AjtailayoutParams
到视图中,只需更改其值即可。 - Juan José Melero Gómez