Android ImageView控件的MaxWidth、MaxHeight不起作用
来源:互联网 发布:安卓版mp3编辑软件 编辑:程序博客网 时间:2024/05/01 21:52
在使用imageview控件时,由于图片大小不一致,需要给图片设置个最大宽高。设置后的代码如下:
LinearLayout ll = new LinearLayout(ConsumeInfo.this);
ll.setOrientation(LinearLayout.HORIZONTAL);
//设置小图标
ImageView imageView = new ImageView(ConsumeInfo.this);
Bitmap bitmap = BitmapFactory.decodeFile((String)mData.get(position).get("imgpath"));
imageView.setImageBitmap(bitmap);
imageView.setMaxHeight(50);
imageView.setMaxWidth(50);
ll.addView(imageView);
运行之后,Imageview 仍然被撑开,难道是MaxWidth,MaxHeight不起作用,抓紧翻阅api文档,找到下面的解释:
An optional argument to supply a maximum width for this view. Only valid if setAdjustViewBounds(boolean)
has been set to true.
文档中说得很清楚,抓紧修改如下:
LinearLayout ll = new LinearLayout(ConsumeInfo.this);
ll.setOrientation(LinearLayout.HORIZONTAL);
//设置小图标
ImageView imageView = new ImageView(ConsumeInfo.this);
Bitmap bitmap = BitmapFactory.decodeFile((String)mData.get(position).get("imgpath"));
imageView.setImageBitmap(bitmap);
imageView.setAdjustViewBounds(true);
imageView.setMaxHeight(50);
imageView.setMaxWidth(50);
ll.addView(imageView);
再次运行,竟然可以了!
转载于:http://blog.csdn.net/love__coder/article/details/6678182- Android ImageView控件的MaxWidth、MaxHeight不起作用
- Android ImageView控件的MaxWidth、MaxHeight不起作用
- Android ImageView控件的MaxWidth、MaxHeight不起作用
- Android ImageView控件的MaxWidth、MaxHeight不起作用
- Android ImageView控件中的MaxWidth,MaxHeight不起作用
- Android ImageView maxHeight maxWidth
- ImageView设置maxWidth与maxHeight不起作用
- Android的ImageView如何maxHeight与maxWidth生效
- android:maxHeight,android:maxWidth失效,不起作用
- android:maxHeight,android:maxWidth失效
- ImageView 设置 maxWidth/maxHeight 和 adjustViewBounds
- ImageView的android:maxHeight,android:minHeight的正确设置
- ImageView的android:maxHeight,android:minHeight的正确设置
- ImageView的android:maxHeight,android:minHeight的正确设置
- ImageView的android:maxHeight,android:minHeight的正确设置
- ImageView的android:maxHeight,android:minHeight的正确设置
- ImageView maxHeight无效问题
- ImageView控件自适应图片(解决ImageView属性scaleType和adjustViewBounds不起作用的兼容问题)
- 1.只有.mdf和ldf文件如何导入数据库?2.eclipse中如何导入项目
- fastboot的使用
- Linux sort命令详解
- 纯js脚本1k大小的3D玫瑰_个人整理的代码(源码)
- wince 下 Datagrid 列宽控制及Datagrid 整行选中模式实现
- Android ImageView控件的MaxWidth、MaxHeight不起作用
- bulkload出现了KeeperException问题
- java java.lang.NoClassDefFoundError 的解决办法
- JS 判断 flash 插件 是否安装 版本是多少
- 怎样写诗
- 在线安全培训国外
- 设置jdk环境变量时lib中的rt.jar ,dt.jar ,tool.jar是什么 ,作用是什么
- Android中自定义的加载对话框和加载条
- ListView 中的TextView实现跑马灯效果