Code example for FrameLayout

Methods: addViewremoveAllViews, getHeight, getWidth

0
        return handled;
    } 
 
    protected void startDragging(Bitmap bitmap, int x, int y) {
        mDragging = true;
        mDragContainer.removeAllViews();
        mDraggingImageView = new ImageView(mContext);
        mDraggingImageView.setImageBitmap(bitmap);
        mDraggingImageView.setScaleType(ImageView.ScaleType.CENTER);
        mDragContainer.addView(mDraggingImageView);
 
        if (!mContainerAttached) {
            mWindowManager.addView(mDragContainer, mWindowParams);
            mContainerAttached = true;
        } 
    } 
 
    /** 
     * Tells this drag manager that no views are being dragged 
     */ 
    public void stopDragging() { 
        mDragging = false;
        mDraggedView = null;
        if (mContainerAttached) {
            mWindowManager.removeView(mDragContainer);
            mContainerAttached = false;
        } 
        mDragContainer.removeAllViews();
    } 
 
    /** 
     * Tells this drag manager that the given child view is being dragged 
     *  
     * @param draggedView 
     * @param event 
     */ 
    public void startDragging(View draggedView, MotionEvent event) {
        startDragging(draggedView, event, 0);
    } 
 
    /** 
     * Tells this drag manager that the given child view is being dragged 
     *  
     * @param draggedView 
     * @param event 
     * @param yOffset 
     *            The number of pixels to subtract from the y-position of the dragged view 
     */ 
    public void startDragging(View draggedView, MotionEvent event, int yOffset) {
        mDraggedView = draggedView;
 
        int x = (int) event.getX();
        int y = (int) event.getY();
 
        Bitmap bitmap = createBitmapFromView(draggedView);
        startDragging(bitmap, x, y);
 
        // Set offsets used when scrolling the ImageView 
        mOffset[0] = x + ((mDragContainer.getWidth() / 2) - (bitmap.getWidth() / 2));
        mOffset[1] = mDragContainer.getHeight() / 2 - (draggedView.getHeight() / 2);
 
        scrollDraggingImage(x, y - yOffset);
    } 
 
    private void scrollDraggingImage(int x, int y) {