zoukankan      html  css  js  c++  java
  • View转化为bitmap

    private Bitmap getViewBitmap(View v) {   
            v.clearFocus();   
            v.setPressed(false);   
       
            boolean willNotCache = v.willNotCacheDrawing();   
            v.setWillNotCacheDrawing(false);   
       
            // Reset the drawing cache background color to fully transparent   
            // for the duration of this operation   
            int color = v.getDrawingCacheBackgroundColor();   
            v.setDrawingCacheBackgroundColor(0);   
       
            if (color != 0) {   
                v.destroyDrawingCache();   
            }   
            v.buildDrawingCache();   
            Bitmap cacheBitmap = v.getDrawingCache();   
            if (cacheBitmap == null) {   
                Log.e("TTTTTTTTActivity", "failed getViewBitmap(" + v + ")", new RuntimeException());   
                return null;   
            }   
       
            Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);   
       
            // Restore the view   
            v.destroyDrawingCache();   
            v.setWillNotCacheDrawing(willNotCache);   
            v.setDrawingCacheBackgroundColor(color);   
       
            return bitmap;   
        }  
    

      

  • 相关阅读:
    2. redis的数据类型
    1. redis简介
    6. 职责链设计模式
    9. 桥梁设计模式
    一. 序言
    网络中常见的面试题
    JDBC
    Mybatis批量操作数据的方法
    ORM框架的概述
    Mybatis动态sql技术
  • 原文地址:https://www.cnblogs.com/qgli/p/3173556.html
Copyright © 2011-2022 走看看