当前位置: 首页>>代码示例>>Java>>正文


Java View.setDrawingCacheBackgroundColor方法代码示例

本文整理汇总了Java中android.view.View.setDrawingCacheBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java View.setDrawingCacheBackgroundColor方法的具体用法?Java View.setDrawingCacheBackgroundColor怎么用?Java View.setDrawingCacheBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setDrawingCacheBackgroundColor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getViewBitmap

import android.view.View; //导入方法依赖的package包/类
public static Bitmap getViewBitmap(View comBitmap, int width, int height) {
    Bitmap bitmap = null;
    if (comBitmap != null) {
        comBitmap.clearFocus();
        comBitmap.setPressed(false);

        boolean willNotCache = comBitmap.willNotCacheDrawing();
        comBitmap.setWillNotCacheDrawing(false);

        // Reset the drawing cache background color to fully transparent
        // for the duration of this operation
        int color = comBitmap.getDrawingCacheBackgroundColor();
        comBitmap.setDrawingCacheBackgroundColor(0xffffff);
        float alpha = comBitmap.getAlpha();
        comBitmap.setAlpha(1.0f);

        if (color != 0) {
            comBitmap.destroyDrawingCache();
        }

        int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);
        int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);
        comBitmap.measure(widthSpec, heightSpec);
        comBitmap.layout(comBitmap.getLeft(), comBitmap.getTop(), comBitmap.getLeft()+width, comBitmap.getTop()+height);

        comBitmap.buildDrawingCache();
        Bitmap cacheBitmap = comBitmap.getDrawingCache();
        if (cacheBitmap == null) {
            Log.e("view.ProcessImageToBlur", "failed getViewBitmap(" + comBitmap);
            return null;
        }
        bitmap = Bitmap.createBitmap(cacheBitmap);
        // Restore the view
        comBitmap.setAlpha(alpha);
        comBitmap.destroyDrawingCache();
        comBitmap.setWillNotCacheDrawing(willNotCache);
        comBitmap.setDrawingCacheBackgroundColor(color);
    }
    return bitmap;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:41,代码来源:BitmapCommonUtils.java

示例2: getViewBitmap

import android.view.View; //导入方法依赖的package包/类
private Bitmap getViewBitmap(View v) {
    v.clearFocus();
    v.setPressed(false);

    boolean willNotCache = v.willNotCacheDrawing();
    v.setWillNotCacheDrawing(false);

    int color = v.getDrawingCacheBackgroundColor();
    v.setDrawingCacheBackgroundColor(0);

    if (color != 0) {
        v.destroyDrawingCache();
    }
    v.buildDrawingCache();
    Bitmap cacheBitmap = v.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }

    Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);

    v.destroyDrawingCache();
    v.setWillNotCacheDrawing(willNotCache);
    v.setDrawingCacheBackgroundColor(color);

    return bitmap;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:28,代码来源:DragDropHelper.java

示例3: getBitmapFromView2

import android.view.View; //导入方法依赖的package包/类
/**
 * 把一个View的对象转换成bitmap
 *
 * @param view View
 * @return Bitmap
 */
public static Bitmap getBitmapFromView2(View view) {
    if (view == null) {
        return null;
    }
    view.clearFocus();
    view.setPressed(false);

    // 能画缓存就返回false
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(0);
    if (color != 0) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        XPrintUtils.e( "failed getViewBitmap(" + view + ") -->"+
                    new RuntimeException());
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:36,代码来源:XBitmapUtils.java

示例4: obtainView

import android.view.View; //导入方法依赖的package包/类
View obtainView(int position, boolean[] isScrap) {
    View child;
    isScrap[0] = false;
    View scrapView = this.mRecycler.getScrapView(position);
    if (scrapView != null) {
        child = this.mAdapter.getView(position, scrapView, this);
        if (child != scrapView) {
            DebugUtil.i("obtainView");
            this.mRecycler.addScrapView(scrapView);
            if (this.mCacheColorHint != 0) {
                child.setDrawingCacheBackgroundColor(this.mCacheColorHint);
            }
        } else {
            isScrap[0] = true;
            dispatchFinishTemporaryDetach(child);
        }
    } else {
        DebugUtil.i("makeView:" + position);
        child = this.mAdapter.getView(position, null, this);
        if (this.mCacheColorHint != 0) {
            child.setDrawingCacheBackgroundColor(this.mCacheColorHint);
        }
    }
    return child;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:PLA_AbsListView.java

示例5: setCacheColorHint

import android.view.View; //导入方法依赖的package包/类
void setCacheColorHint(int color) {
    int i;
    Stack<View> scrap;
    int scrapCount;
    if (this.mViewTypeCount == 1) {
        scrap = this.mCurrentScrap;
        scrapCount = scrap.size();
        for (i = 0; i < scrapCount; i++) {
            ((View) scrap.get(i)).setDrawingCacheBackgroundColor(color);
        }
    } else {
        int typeCount = this.mViewTypeCount;
        for (i = 0; i < typeCount; i++) {
            scrap = this.mScrapViews[i];
            scrapCount = scrap.size();
            for (int j = 0; j < scrapCount; j++) {
                ((View) scrap.get(i)).setDrawingCacheBackgroundColor(color);
            }
        }
    }
    for (View victim : this.mActiveViews) {
        if (victim != null) {
            victim.setDrawingCacheBackgroundColor(color);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:PLA_AbsListView$RecycleBin.java

示例6: convertViewToBitmap

import android.view.View; //导入方法依赖的package包/类
public static Bitmap convertViewToBitmap(View view) {
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(0);
    if (color != 0) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:BitmapUtil.java

示例7: getViewBitmap

import android.view.View; //导入方法依赖的package包/类
public static 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("Folder", "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;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:32,代码来源:MyBitmapUtil.java

示例8: toBitmap

import android.view.View; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
        LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:54,代码来源:ConvertUtils.java

示例9: toBitmap

import android.view.View; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
       // LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:54,代码来源:ConvertUtils.java

示例10: measureHeightOfChildren

import android.view.View; //导入方法依赖的package包/类
private int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition,
        final int maxHeight, int disallowPartialChildPosition) {

    final ListAdapter adapter = mAdapter;
    if (adapter == null) {
        return mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
    }

    // Include the padding of the list
    int returnedHeight = mDropDownList.getListPaddingTop() + mDropDownList.getListPaddingBottom();
    final int dividerHeight = ((mDropDownList.getDividerHeight() > 0) && mDropDownList.getDivider() != null) ? mDropDownList.getDividerHeight() : 0;
    // The previous height value that was less than maxHeight and contained
    // no partial children
    int prevHeightWithoutPartialChild = 0;
    int i;
    View child;

    // mItemCount - 1 since endPosition parameter is inclusive
    endPosition = (endPosition == -1/*NO_POSITION*/) ? adapter.getCount() - 1 : endPosition;

    for (i = startPosition; i <= endPosition; ++i) {
        child = mAdapter.getView(i, null, mDropDownList);
        if (mDropDownList.getCacheColorHint() != 0) {
            child.setDrawingCacheBackgroundColor(mDropDownList.getCacheColorHint());
        }

        measureScrapChild(child, i, widthMeasureSpec);

        if (i > 0) {
            // Count the divider for all but one child
            returnedHeight += dividerHeight;
        }

        returnedHeight += child.getMeasuredHeight();

        if (returnedHeight >= maxHeight) {
            // We went over, figure out which height to return.  If returnedHeight > maxHeight,
            // then the i'th position did not fit completely.
            return (disallowPartialChildPosition >= 0) // Disallowing is enabled (> -1)
                        && (i > disallowPartialChildPosition) // We've past the min pos
                        && (prevHeightWithoutPartialChild > 0) // We have a prev height
                        && (returnedHeight != maxHeight) // i'th child did not fit completely
                    ? prevHeightWithoutPartialChild
                    : maxHeight;
        }

        if ((disallowPartialChildPosition >= 0) && (i >= disallowPartialChildPosition)) {
            prevHeightWithoutPartialChild = returnedHeight;
        }
    }

    // At this point, we went through the range of children, and they each
    // completely fit, so return the returnedHeight
    return returnedHeight;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:56,代码来源:IcsListPopupWindow.java

示例11: toBitmap

import android.view.View; //导入方法依赖的package包/类
/**
 * convert View to Bitmap.
 *
 * @param view the view
 * @return the bitmap
 * @link http ://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    //以下代码用于把当前view转化为bitmap(截图)
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    cacheBitmap.recycle();
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:55,代码来源:ConvertUtils.java

示例12: getBitmapFromView

import android.view.View; //导入方法依赖的package包/类
private static Bitmap getBitmapFromView(View view, int tryTime, boolean forceHighQuality) {
    boolean willNotCacheDrawingBefore = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);

    int drawingCacheBackgroundColorBefore = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(0);
    int drawingCacheQualityBefore = view.getDrawingCacheQuality();
    if (drawingCacheBackgroundColorBefore != 0) {
        view.destroyDrawingCache();
    }
    if (tryTime > 1) {
        view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null || cacheBitmap.isRecycled()) {
        view.setDrawingCacheQuality(drawingCacheQualityBefore);
        view.setWillNotCacheDrawing(willNotCacheDrawingBefore);
        view.setDrawingCacheBackgroundColor(drawingCacheBackgroundColorBefore);

        if (tryTime < TRY_GET_BITMAP_FROM_VIEW_MAX_REPEAT_TIME) {
            handleOutOfMemory();
            return getBitmapFromView(view, tryTime + 1, forceHighQuality);
        }
        return null;
    }

    Bitmap bitmap = createBitmap(cacheBitmap, cacheBitmap.getWidth(), cacheBitmap.getHeight(), forceHighQuality || tryTime == 1 ? Config.ARGB_8888
            : Config.ARGB_4444);

    if (bitmap == cacheBitmap) {
        bitmap = createBitmap(cacheBitmap);
    }

    view.destroyDrawingCache();

    view.setDrawingCacheQuality(drawingCacheQualityBefore);
    view.setWillNotCacheDrawing(willNotCacheDrawingBefore);
    view.setDrawingCacheBackgroundColor(drawingCacheBackgroundColorBefore);

    return bitmap;
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:43,代码来源:BitmapUtils.java

示例13: obtainView

import android.view.View; //导入方法依赖的package包/类
/**
 * Get a view and have it show the data associated with the specified
 * position. This is called when we have already discovered that the view is
 * not available for reuse in the recycle bin. The only choices left are
 * converting an old view or making a new one.
 *
 * @param position The position to display
 * @param isScrap Array of at least 1 boolean, the first entry will become true if
 *                the returned view was taken from the scrap heap, false if otherwise.
 *
 * @return A view displaying the data associated with the specified position
 */
@SuppressWarnings("deprecation")
View obtainView(int position, boolean[] isScrap) {
    isScrap[0] = false;
    View scrapView;

    scrapView = mRecycler.getScrapView(position);

    View child;
    if (scrapView != null) {
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.RECYCLE_FROM_SCRAP_HEAP,
                    position, -1);
        }

        child = mAdapter.getView(position, scrapView, this);

        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW,
                    position, getChildCount());
        }

        if (child != scrapView) {
            DebugUtil.i("obtainView");
            mRecycler.addScrapView(scrapView);
            if (mCacheColorHint != 0) {
                child.setDrawingCacheBackgroundColor(mCacheColorHint);
            }
            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
                        position, -1);
            }
        } else {
            isScrap[0] = true;
            //child.dispatchFinishTemporaryDetach();
            dispatchFinishTemporaryDetach(child);
        }
    } else {
        DebugUtil.i("makeView:" + position);
        child = mAdapter.getView(position, null, this);
        if (mCacheColorHint != 0) {
            child.setDrawingCacheBackgroundColor(mCacheColorHint);
        }
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.NEW_VIEW,
                    position, getChildCount());
        }
    }

    return child;
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:63,代码来源:PLA_AbsListView.java


注:本文中的android.view.View.setDrawingCacheBackgroundColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。