记录ImageView.adjustViewBounds属性 遇到的问题
来源:互联网 发布:网页编程是什么 编辑:程序博客网 时间:2024/06/17 08:57
最近项目开发遇到一个奇怪 的问题,同样的代码在同时的OPPO手机上是显示的,在我的小米4上不显示。细看代码ImageView设置了adjustViewBounds属性。具体如下:
<ImageView
android:id="@+id/iv_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:maxHeight="250dp" />
于是通过如下代码打印发现 ImageView的宽高都为0,但是真实的Image宽高是正常的,所以导致不显示:
iv_pic.post(new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
//ImageView的宽和高
System.out.println("iv_W = " + iv_pic.getWidth() + ", iv_H = " + iv_pic.getHeight());
//获得ImageView中Image的真实宽高,
int dw = iv_pic.getDrawable().getBounds().width();
int dh = iv_pic.getDrawable().getBounds().height();
System.out.println("drawable_X = " + dw + ", drawable_Y = " + dh);
}});
最后修改ImageView去掉android:contentDescription和android:maxHeight这俩个属性,搞定收工
<ImageView
android:id="@+id/iv_pic_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@null"
android:scaleType="fitXY"
/>
- 记录ImageView.adjustViewBounds属性 遇到的问题
- ImageView的android:adjustViewBounds属性
- ImageView的android:adjustViewBounds属性
- ImageView的android:adjustViewBounds属性
- ImageView的android:adjustViewBounds属性
- ImageView的scaleType属性与adjustViewBounds属性
- android ImageView android:adjustViewBounds属性的作用。
- android ImageView android:adjustViewBounds属性的作用
- 结合源码分析ImageView的adjustViewBounds属性
- ImageView的adjustViewBounds属性再解读
- ImageView的scaleType与adjustViewBounds属性
- ImageView.adjustViewBounds属性
- Android ImageView的scaleType属性与adjustViewBounds属性与图片自适应问题
- imageView高度与显示问题:scaleType属性,adjustViewBounds属性
- Android ImageView的scaleType属性与adjustViewBounds属性
- Android ImageView的scaleType属性与adjustViewBounds属性
- Android ImageView的scaleType属性与adjustViewBounds属性
- Android ImageView的scaleType属性与adjustViewBounds属性
- 九个案例让你一分钟读懂“执行力”!
- Linux下删除oracle实例
- JS函数闭包与对象作用域
- Android判断设备是否为模拟器
- 第四周实践项目5-猴子选大王
- 记录ImageView.adjustViewBounds属性 遇到的问题
- PHP文件读写类
- tomcat上部署web项目
- 利用逗号分隔符批量生成插入语句
- 尾递归~~~
- 汇编语言指令
- android 蓝牙app代码
- Windows环境ProtocolBuffer安装及入门使用
- dp,sp,px,pt区别