想做一个动态桌面,需要知道图标在桌面上的坐标,请各位大侠出招,谢谢了

解决方案 »

  1.   

    资料:Android Launcher中取得桌面所有图标的左上角坐标Java代码
      /**
      * 取得所有桌面图标的左上角坐标值
      * @ author: 叶里的猫
      *@return 返回坐标数组
      */
      public int [][] getAllChildCoordinate(){
      int size = this.getChildCount() ;
      int [][] coordinates = new int [size][2];
      for(int i=0;i< p> 
      View child = this.getChildAt(i);
      if(child instanceof BubbleTextView){
      BubbleTextView btv = (BubbleTextView)child ;
      //横坐标
      int left = btv.getLeft() ;
      //纵坐标
      int top = btv.getTop() ;
      coordinates[i][0] = left ;
      coordinates[i][1] = top ;
      }
      }
      return coordinates ;
      }
      /**
      * 取得所有桌面图标的左上角坐标值
      * @ author: 叶里的猫
      *@return 返回坐标数组
      */
      public int [][] getAllChildCoordinate(){
      int size = this.getChildCount() ;
      int [][] coordinates = new int [size][2];
      for(int i=0;i< p> 
      View child = this.getChildAt(i);
      if(child instanceof BubbleTextView){
      BubbleTextView btv = (BubbleTextView)child ;
      //横坐标
      int left = btv.getLeft() ;
      //纵坐标
      int top = btv.getTop() ;
      coordinates[i][0] = left ;
      coordinates[i][1] = top ;
      }
      }
      return coordinates ;
      }