Skip to content Skip to sidebar Skip to footer

Saving The Current View As A Bitmap

I've already saw lots of questions like this one around SO - but i can't get what i'm doing working (tried several times). Thats why i'm asking a probably repeated question. On the

Solution 1:

You try to add this listener to the onCreate event:

myCustomView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        myCustomView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        do_your_logic_to_save_bitmap_from_view;
    }
});

addOnGlobalLayoutListener will register a callback to be invoked when the global layout state or the visibility of views within the view tree changes. For example when the view is rendered completely.


Post a Comment for "Saving The Current View As A Bitmap"