01 /**
02      * @note 获取该activity所有view
03      * @author liuh
04      * */
05     public List<View> getAllChildViews() {
06         View view = this.getWindow().getDecorView();
07         return getAllChildViews(view);
08     }
09  
10     private List<View> getAllChildViews(View view) {
11         List<View> allchildren = new ArrayList<View>();
12         if (view instanceof ViewGroup) {
13             ViewGroup vp = (ViewGroup) view;
14             for (int i = 0; i < vp.getChildCount(); i++) {
15                 View viewchild = vp.getChildAt(i);
16                 allchildren.add(viewchild);
17                 allchildren.addAll(getAllChildViews(viewchild));
18             }
19         }
20         return allchildren;
21     }

相关文章:

  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-07-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
相关资源
相似解决方案