Code example for FrameLayout

Methods: measuresetBackgroundlayoutdraw, dispatchOnPreDraw, setAttachInfo

2
                    drawableResource.getResourceType() != ResourceType.DRAWABLE) {
                return Status.ERROR_NOT_A_DRAWABLE.createResult(); 
            } 
 
            // create a simple FrameLayout 
            FrameLayout content = new FrameLayout(context);
 
            // get the actual Drawable object to draw 
            Drawable d = ResourceHelper.getDrawable(drawableResource, context);
            content.setBackground(d);
 
            // set the AttachInfo on the root view. 
            AttachInfo_Accessor.setAttachInfo(content);
 
 
            // measure 
            int w = hardwareConfig.getScreenWidth();
            int h = hardwareConfig.getScreenHeight();
            int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
            int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);
            content.measure(w_spec, h_spec);
 
            // now do the layout. 
            content.layout(0, 0, w, h);
 
            // preDraw setup 
            AttachInfo_Accessor.dispatchOnPreDraw(content);
 
            // draw into a new image 
            BufferedImage image = getImage(w, h);
 
            // create an Android bitmap around the BufferedImage 
            Bitmap bitmap = Bitmap_Delegate.createBitmap(image,
                    true /*isMutable*/, hardwareConfig.getDensity());
 
            // create a Canvas around the Android bitmap 
            Canvas canvas = new Canvas(bitmap);
            canvas.setDensity(hardwareConfig.getDensity().getDpiValue());
 
            // and draw 
            content.draw(canvas);
 
            return Status.SUCCESS.createResult(image);
        } catch (IOException e) {
            return ERROR_UNKNOWN.createResult(e.getMessage(), e);
        }