现在的位置: 首页 > 综合 > 正文

android developer tips—干掉adb侵入者命令和activity中获取控件宽高方法

2017年02月25日 ⁄ 综合 ⁄ 共 655字 ⁄ 字号 评论关闭

 netstat -ano | findstr "5037" 找出监听5037端口的 PID ,然后 tasklist | findstr "PID number"
查看占用的进程,kill之。

*#717717#*拨号处输入,专治小米部分不服rom

获取控件宽高。一:

  ViewTreeObserver vto = mBtnSend.getViewTreeObserver(); 
  vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
  @Override 
  public void onGlobalLayout() { 
  int height = mBtnSend.getMeasuredHeight(); 
  int width = mBtnSend.getMeasuredWidth(); 
  System.out.println("height:" + height + "  " + "width:" + width); 
  }   
  }); 

二:

在Activity里重写方法 
  public void onWindowFocusChanged(boolean hasFocus); 

  在窗口第一次获得焦点的时候,肯定能获取到控件的width,height。

三:

textView.getViewTreeObserver().addOnPreDrawListener( 
 new  OnPreDrawListener() { 
 public boolean onPreDraw() {   
 //这里textView已经初始化完毕,你可以得到所有属性             
 return true  ;    
 }  }); 

抱歉!评论已关闭.