如何在代码中改变 ImageView的大小, 我用 imageview.setMaxHeight(150); imageview.setMaxWidth(150);来设置好像不行, 下面是layout中的 ImageView
<ImageView android:id="@+id/imv_bg" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="200dip"
android:maxHeight="200dip"
android:scaleType="fitCenter" android:background="@drawable/wifi"
android:layout_marginTop="65dip" android:layout_centerHorizontal="true">
</ImageView>
<ImageView android:id="@+id/imv_bg" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:maxWidth="200dip"
android:maxHeight="200dip"
android:scaleType="fitCenter" android:background="@drawable/wifi"
android:layout_marginTop="65dip" android:layout_centerHorizontal="true">
</ImageView>
TextView textView = new TextView(this);
LayoutParams mParams = new LayoutParams(100, 100);
textView .setLayoutParams(mParams);
imageView改大小要些个LayoutParams了,可以用绝对布局的。最好还是向楼上说的用个bitmap 改matrix。
2) set maxWidth and maxHeight to 100
3) set the height and width layout params to WRAP_CONTENT.