//遍历当前界面所有控件
public List<View> getAllChildViews(){
View view= this.getWindows.getDecorView();
return getAllChildViews(view);
}
//遍历一个ViewGroup
public LIst<View> getAllChildViews(View view){
List<View> views = new ArrayList<View>();
if(view instanceof ViewGroup){
ViewGroup vp = (ViewGroup)view;
for(int i = 0;i<vp.getChildCount();i++){
View viewchild=vp.getChildAt(i);
views.add(viewchild);
views.addAll(getAllChildViews(viewchild)));
}
}
return views;
}