点击启动activity报这个错,
原因出在对宽高赋值的逻辑,没有在OnGlobalLayoutListener中实现
ViewTreeObserver vto = editText.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { editText.getViewTreeObserver().removeOnGlobalLayoutListener(this); mImgViewWidth = editText.getMeasuredWidth(); //这个值在view绘制完成后才会被回调赋值 mInsertedImgWidth = mImgViewWidth * 0.8f; //将日志显示 updateContent(editText, currentDiary.getContent()); } });