final int scrapCount = scrap.size(); for (int i = 0; i < scrapCount; i++) { scrap.get(i).setDrawingCacheBackgroundColor(color); final int scrapCount = scrap.size(); for (int j = 0; j < scrapCount; j++) { scrap.get(i).setDrawingCacheBackgroundColor(color); final View victim = activeViews[i]; if (victim != null) { victim.setDrawingCacheBackgroundColor(color);
/** * When set to a non-zero value, the cache color hint indicates that this list is always drawn * on top of a solid, single-color, opaque background * * @param color The background color */ public void setCacheColorHint(int color) { if (color != mCacheColorHint) { mCacheColorHint = color; int count = getChildCount(); for (int i = 0; i < count; i++) { getChildAt(i).setDrawingCacheBackgroundColor(color); } mRecycler.setCacheColorHint(color); } }
view.setDrawingCacheBackgroundColor(0); float alpha = view.getAlpha(); view.setAlpha(1.0f); view.destroyDrawingCache(); view.setWillNotCacheDrawing(willNotCache); view.setDrawingCacheBackgroundColor(color);
view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素) if (color != Color.WHITE) { view.destroyDrawingCache(); view.setDrawingCacheBackgroundColor(color); return bitmap;
mRecycler.addScrapView(scrapView); if (mCacheColorHint != 0) { child.setDrawingCacheBackgroundColor(mCacheColorHint); child = mAdapter.getView(position, null, this); if (mCacheColorHint != 0) { child.setDrawingCacheBackgroundColor(mCacheColorHint);
/** * Draw the view into a 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(TAG, "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; }
view.setWillNotCacheDrawing(false); int color = view.getDrawingCacheBackgroundColor(); view.setDrawingCacheBackgroundColor(0); if (color != 0) { view.destroyDrawingCache(); view.setDrawingCacheBackgroundColor(color); return bitmap;
view.setWillNotCacheDrawing(false); int color = view.getDrawingCacheBackgroundColor(); view.setDrawingCacheBackgroundColor(0); if (color != 0) { view.destroyDrawingCache(); view.setDrawingCacheBackgroundColor(color); return bitmap;
/** * 设置View的背景颜色而不改变View的shape * todo 这里用强转的时候会报错,暂时没有更好的解决方法所以用了try-catch * @param v * @param color */ public static void setBackgroundWithGradientDrawable(View v,int color){ if(v!=null){ try { ((GradientDrawable)v.getBackground()).setColor(color); }catch (ClassCastException e){ v.setDrawingCacheBackgroundColor(color); Log.d("WIVE","set bcakground "+e.getMessage()); } } } }
public void run(RapidParserObject object, Object view, Var value) { ((View)view).setDrawingCacheBackgroundColor(Color.parseColor("#" + value.getString())); } }
/** * When set to a non-zero value, the cache color hint indicates that this list is always drawn on top of a solid, single-color, opaque background * Parameters: * @param color the hint color */ public void setCacheColorHint(int color) { // TODO Auto-generated method stub if (color != mCacheColorHint) { mCacheColorHint = color; int count = getChildCount(); for (int i = 0; i < count; i++) { getChildAt(i).setDrawingCacheBackgroundColor(color); } } }
/** * When set to a non-zero value, the cache color hint indicates that this list is always drawn on top of a solid, single-color, * opaque background. * * Zero means that what's behind this object is translucent (non solid) or is not made of a single color. This hint will not * affect any existing background drawable set on this view ( typically set via {@link #setBackgroundDrawable(Drawable)}). * * @param color * The background color */ public void setCacheColorHint( int color ) { if ( color != mCacheColorHint ) { mCacheColorHint = color; int count = getChildCount(); for ( int i = 0; i < count; i++ ) { getChildAt( i ).setDrawingCacheBackgroundColor( color ); } mRecycler.setCacheColorHint( color ); } }
v.setDrawingCacheBackgroundColor(0); float alpha = v.getAlpha(); v.setAlpha(1.0f); v.setAlpha(alpha); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color);
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; }
v.setDrawingCacheBackgroundColor(Color.TRANSPARENT); v.setDrawingCacheBackgroundColor(color); return null; v.setDrawingCacheBackgroundColor(color);
v.setDrawingCacheBackgroundColor(Color.TRANSPARENT); v.setDrawingCacheBackgroundColor(color); return null; v.setDrawingCacheBackgroundColor(color);
/** * 普通View截屏 * @param v * @param fileName * @return */ public static Bitmap screenShotNormalView(View v, String fileName) { 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(); Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // Restore the view v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
v.setDrawingCacheBackgroundColor(0); v.setDrawingCacheBackgroundColor(color);
v.setDrawingCacheBackgroundColor(0); v.setDrawingCacheBackgroundColor(color);