當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。