Rendering Android webview to bitmap, html5 javascript , callback issue

前端 未结 1 680
长发绾君心
长发绾君心 2020-12-09 23:04

I have an activity with a button and an image and a webview. My goal is to load a page, then execute javascript on it to draw graphics using HTML5 etc.

The height of

1条回答
  •  离开以前
    2020-12-09 23:23

    Found a solution, which was to change the renderCoupon to this:

    void renderCoupon(final int width,final int height){
    
        mWeb.postDelayed(new Runnable() {
    
            @Override
            public void run() {
                // TODO Auto-generated method stub
                bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
                final Canvas c =new Canvas(bitmap);
                mWeb.draw(c);
    
                imgView.setMinimumWidth(width);
                imgView.setMinimumHeight(height);
                imgView.setImageBitmap(bitmap);
                imgView.setVisibility(View.VISIBLE);
            }
        }, 100);
    }
    

    And of course I removed the Sleep stuff in my callback. Thanks to my collegue who tipped me about this. :)

    0 讨论(0)
提交回复
热议问题