代码如下:

 private void TvOverFlowed(final TextView textView,final View img) {

ViewTreeObserver vto = textView.getViewTreeObserver();   
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
   @SuppressWarnings("deprecation")
@Override   
   public void onGlobalLayout() { 
    textView.getViewTreeObserver().removeGlobalOnLayoutListener(this); 
    textView.getHeight();
    double w0=textView.getWidth();//控件宽度
    double w1=textView.getPaint().measureText(textView.getText().toString());//文本宽度
    if(w1>=w0) img.setVisibility(View.VISIBLE);//需要换行就显示该控件
   
   }   
});

}


需要注意的是getWidth()的使用,这里有:http://www.bkjia.com/Androidjc/890740.html

更多相关文章

  1. Android控件开发之四----ListView(1)
  2. Android控件属性大全[整理]
  3. Android控件开发
  4. Android 调用相册 拍照 实现系统控件缩放 切割图片
  5. android 自定义时间控件
  6. Android软键盘弹出时把布局顶上去,控件乱套解决方法

随机推荐

  1. Android中运用Pull解析器读取XML文件
  2. Android RIL源码分析(2)
  3. Android 3D引擎之CatCake----编译hello_c
  4. Andriod 开发之微信分享接口
  5. Android中的Intent详解
  6. 【Android】Android背景选择器selector用
  7. Java/Android引用类型及其使用分析
  8. Android Activity切换动画overridePendin
  9. org.json.JSONException: End of input a
  10. Android之使用Pull解析Xml数据