convert Android activity layout to any image format

空扰寡人 提交于 2019-12-11 09:22:07

问题


Am using Linear layout with is more then the mobile screen size. with visibility is hidden that layout have some content inside. I need to take export that complete activity as image format see the reference image i attached

How to get the complete activity as image (jpeg or any other)

I tried with this code but i can not able to get the full width image. i got only up to the mobile screen

Please correct it

View  layoutview = (LinearLayout) findViewById(R.id.layout_outer);
        layoutview.setDrawingCacheEnabled(true);
        Bitmap bimg = layoutview.getDrawingCache();             

        File imgPath = new File("/sdcard/sample.png");
        FileOutputStream fOs = null;
        try {
            fOs = new FileOutputStream(imgPath);
            bimg.compress(Bitmap.CompressFormat.PNG, 100, fOs);
            fOs.flush();
            fOs.close();
            btndsbExport.setVisibility(View.VISIBLE);


        }catch (FileNotFoundException e) {
            e.printStackTrace();


    enter code here
        } catch (Exception e) {
            e.printStackTrace();

        }

来源:https://stackoverflow.com/questions/16942641/convert-android-activity-layout-to-any-image-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!