解决方案 »

  1.   

       跟go Launcher 屏幕预览效果差不多.
      

  2.   

       呵呵  不要小看了, 用过go Launcher没? 大致跟它那种浏览screen 差不多,可以增加screen 也可以删除
      

  3.   

    private void showPreviews(final View anchor, int start, int end) 
     {
            final Resources resources = getResources();
            final lhkworkspace workspace = mWorkspace;
            System.out.println("end=" +end);
            CellLayout cell = ((CellLayout) workspace.getChildAt(start));
            
            float max = workspace.getChildCount();
            
            final Rect r = new Rect();//8*6
            resources.getDrawable(R.drawable.preview_background).getPadding(r);
            int extraW = (int) ((r.left + r.right) * max); //40
            int extraH = r.top + r.bottom; //6
            System.out.println("extraW=" +extraW);
            System.out.println("extraH=" +extraH);
            
            int aW = cell.getWidth() - extraW;
            System.out.println("cell.getWidth()=" +cell.getWidth());//0
            float w = aW / max;         int width = cell.getWidth();
            int height = cell.getHeight();
            System.out.println("cell.getHeight()=" +cell.getHeight());//0
            int x = cell.getLeftPadding();//6
            int y = cell.getTopPadding();//0
            System.out.println("x=" +x);
            System.out.println("y=" +y);
            width -= (x + cell.getRightPadding());
            height -= (y + cell.getBottomPadding());
            System.out.println("cell.getRightPadding()=" +cell.getRightPadding());//59
            System.out.println("cell.getBottomPadding()=" +cell.getBottomPadding());//0
            
            float scale = w / width;         int count = end - start;         final float sWidth = width * scale;
            float sHeight = height * scale;         LinearLayout preview = new LinearLayout(this);         PreviewTouchHandler handler = new PreviewTouchHandler(anchor);
            ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(count);
            System.out.println(sWidth);
            System.out.println(sHeight);
            for (int i = start; i < end; i++) 
            {
                ImageView image = new ImageView(this);
                cell = (CellLayout) workspace.getChildAt(i);             final Bitmap bitmap = Bitmap.createBitmap((int) 30, (int) 40,
                        Bitmap.Config.ARGB_8888);             final Canvas c = new Canvas(bitmap);
                c.scale(scale, scale);
                c.translate(-cell.getLeftPadding(), -cell.getTopPadding());
                cell.dispatchDraw(c);             image.setBackgroundDrawable(resources.getDrawable(R.drawable.preview_background));
                image.setImageBitmap(bitmap);
                image.setTag(i);
                image.setOnClickListener(handler);
                image.setOnFocusChangeListener(handler);
                image.setFocusable(true);
                if (i == mWorkspace.getCurrentScreen()) image.requestFocus();             preview.addView(image,
                        LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);             bitmaps.add(bitmap);            
            }         final PopupWindow p = new PopupWindow(this);
            p.setContentView(preview);
            p.setWidth((int) (200));
            p.setHeight((int) (40));
            p.setAnimationStyle(R.style.AnimationPreview);
            p.setOutsideTouchable(true);
            p.setFocusable(true);
            p.setBackgroundDrawable(new ColorDrawable(0));
            p.showAsDropDown(anchor, 0, 0);         p.setOnDismissListener(new PopupWindow.OnDismissListener() 
            {
                public void onDismiss() 
                {
                    dismissPreview(anchor);
                }
            });         anchor.setTag(p);
            anchor.setTag(R.id.workspace, preview);
            anchor.setTag(R.id.icon, bitmaps);        
        }