View的getWidth,getHeight为0的解决方法
来源:互联网 发布:c语言atm机程序 编辑:程序博客网 时间:2024/05/17 22:52
在Activity文件中就可以重写onWindowFocusChanged方法,在该方法中获得view的width和height
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); textview.getHeight();}
Fragment中不能重写onWindowFocusChanged方法,因此可以使用ViewTreeObserver来添加一个回调,在回调中获得view的width和height
ViewTreeObserver vto = textview.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { int height = textview.getMeasuredHeight(); int width = textview.getMeasuredWidth(); return true; } });
0 0
- View的getWidth,getHeight为0的解决方法
- android view getWidth 和 getHeight 的值为0
- android view getWidth 和 getHeight 的值为0
- android view getWidth 和 getHeight 的值为0
- getWidth() getHeight() ,返回的值为0
- 为何 view.getWidth和view.getHeight 的返回值为0
- view的getWidth() getHeight() 总是返回0 的几种解决方法
- 关于View.getHeight和getWidth为0的解决方案(待深入学习)
- 使用View的getWidth(),getHeight()方法返回0的问题
- TODO:view的getwidth(), getHeight()什么时候会有值
- 关于控件getWidth和getHeight方法都为0的解释及解决方法
- android getWidth() getHeight() 方法返回的值为0
- 为什么View中的getWidth()和getHeight()值为0
- android view.getWidth(), view.getHeight() 返回0的问题的解决方案
- android view.getWidth(), view.getHeight() 返回0的问题的解决方案
- 在java.awt.Image时,getWidth()和getHeight()为-1的解决方法
- View的getWidth/getHeight与getMeasuredWidth/getMeasuredHeight的区别
- View的getWidth/getHeight与getMeasuredWidth/getMeasuredHeight的区别
- 蓝桥杯 历届试题 1119
- 使用闪回拯救我们的数据
- Java虚拟机(JVM)参数配置说明
- Jenkins使用
- 高效的找出两个List中的不同元素
- View的getWidth,getHeight为0的解决方法
- 理解RESTful架构
- 高德地图的基本操作
- iOS DLNA Cyberlink,PlatinumKit库完成DLNA功能
- 解决“Dynamic Web Module 3.0 requires Java 1.6 or newer.”错误
- iOS 文字转音频
- php文件上传
- HTML5游戏开发实践之HTML5框架的使用(一)
- C++11类的新语法和特性