如何在代码中改变 ImageView的大小

myfuture20100 2010-12-21 01:37:52
如何在代码中改变 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>
...全文
28098 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
serverside 2011-11-29
  • 打赏
  • 举报
回复 1
1) set adjustViewBounds to true
2) set maxWidth and maxHeight to 100
3) set the height and width layout params to WRAP_CONTENT.
刍狗万物 2011-08-24
  • 打赏
  • 举报
回复
楼上的楼上好人
bigpretty 2010-12-21
  • 打赏
  • 举报
回复
可以设置控件的大小,我实现过
xzy2046 2010-12-21
  • 打赏
  • 举报
回复
为什么要用imageView呢?做动画?
imageView改大小要些个LayoutParams了,可以用绝对布局的。

最好还是向楼上说的用个bitmap 改matrix。
ameyume 2010-12-21
  • 打赏
  • 举报
回复
myfuture20100 2010-12-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wbaqoo 的回复:]

代码当中有个LayoutParams类,该类就是设置view的大小的
TextView textView = new TextView(this);
LayoutParams mParams = new LayoutParams(100, 100);
textView .setLayoutParams(mParams);
[/Quote]

这个试了下,好像不行哦
wbaqoo 2010-12-21
  • 打赏
  • 举报
回复
代码当中有个LayoutParams类,该类就是设置view的大小的
TextView textView = new TextView(this);
LayoutParams mParams = new LayoutParams(100, 100);
textView .setLayoutParams(mParams);

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧