本文整理汇总了Java中android.view.View.setDrawingCacheEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java View.setDrawingCacheEnabled方法的具体用法?Java View.setDrawingCacheEnabled怎么用?Java View.setDrawingCacheEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setDrawingCacheEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BlurTask
import android.view.View; //导入方法依赖的package包/类
public BlurTask(View target, BlurFactor factor, Callback callback) {
target.setDrawingCacheEnabled(true);
this.res = target.getResources();
this.factor = factor;
this.callback = callback;
target.destroyDrawingCache();
target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
capture = target.getDrawingCache();
contextWeakRef = new WeakReference<>(target.getContext());
}
示例2: addMirrorView
import android.view.View; //导入方法依赖的package包/类
private ImageView addMirrorView(ViewGroup parent, RecyclerView recyclerView, View view) {
view.destroyDrawingCache();
view.setDrawingCacheEnabled(true);
ImageView mirrorView = new ImageView(recyclerView.getContext());
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
mirrorView.setImageBitmap(bitmap);
view.setDrawingCacheEnabled(false);
int[] locations = new int[2];
view.getLocationOnScreen(locations);
int[] parenLocations = new int[2];
recyclerView.getLocationOnScreen(parenLocations);
LayoutParams params = new LayoutParams(bitmap.getWidth(), bitmap.getHeight());
params.setMargins(locations[0], (locations[1] - parenLocations[1]) + UIsUtils.dipToPx(44.0f), 0, 0);
parent.addView(mirrorView, params);
return mirrorView;
}
示例3: snapShotWithoutStatusBar
import android.view.View; //导入方法依赖的package包/类
/**
* 获取当前屏幕截图,不包含状态栏
*
* @param activity
* @return
*/
public static Bitmap snapShotWithoutStatusBar(Activity activity)
{
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
Rect frame = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
int width = getScreenWidth(activity);
int height = getScreenHeight(activity);
Bitmap bp = null;
bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height
- statusBarHeight);
view.destroyDrawingCache();
return bp;
}
示例4: getBitmap
import android.view.View; //导入方法依赖的package包/类
private Bitmap getBitmap() {
Bitmap bitmap = null;
boolean isCrosswalk = false;
try {
Class.forName("org.crosswalk.engine.XWalkWebViewEngine");
isCrosswalk = true;
} catch (Exception e) {
}
if (isCrosswalk) {
webView.getPluginManager().postMessage("captureXWalkBitmap", this);
} else {
View view = webView.getView();//.getRootView();
view.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
}
return bitmap;
}
示例5: setScrollingCacheEnabled
import android.view.View; //导入方法依赖的package包/类
private void setScrollingCacheEnabled(boolean enabled) {
if (mScrollingCacheEnabled != enabled) {
mScrollingCacheEnabled = enabled;
if (USE_CACHE) {
final int size = getChildCount();
for (int i = 0; i < size; ++i) {
final View child = getChildAt(i);
if (child.getVisibility() != GONE) {
child.setDrawingCacheEnabled(enabled);
}
}
}
}
}
示例6: captureWithoutStatusBar
import android.view.View; //导入方法依赖的package包/类
/**
* 获取当前屏幕截图,不包含状态栏
*
* @param activity activity
* @return Bitmap
*/
public static Bitmap captureWithoutStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
int statusBarHeight = BarUtils.getStatusBarHeight(activity);
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
Bitmap ret = Bitmap
.createBitmap(bmp, 0, statusBarHeight, dm.widthPixels,
dm.heightPixels - statusBarHeight);
view.destroyDrawingCache();
return ret;
}
示例7: capture
import android.view.View; //导入方法依赖的package包/类
public static Bitmap capture(View view, float width, float height, boolean scroll, Bitmap.Config config) {
if (!view.isDrawingCacheEnabled()) {
view.setDrawingCacheEnabled(true);
}
if(width==0){
width= MainApp.getInstance().getScreenWidth();
}
if(height==0){
height= MainApp.getInstance().getScreenHeight();
}
Bitmap bitmap = Bitmap.createBitmap((int) width, (int) height, config);
bitmap.eraseColor(Color.WHITE);
Canvas canvas = new Canvas(bitmap);
int left = view.getLeft();
int top = view.getTop();
if (scroll) {
left = view.getScrollX();
top = view.getScrollY();
}
int status = canvas.save();
canvas.translate(-left, -top);
float scale = width / view.getWidth();
canvas.scale(scale, scale, left, top);
view.draw(canvas);
canvas.restoreToCount(status);
Paint alphaPaint = new Paint();
alphaPaint.setColor(Color.TRANSPARENT);
canvas.drawRect(0f, 0f, 1f, height, alphaPaint);
canvas.drawRect(width - 1f, 0f, width, height, alphaPaint);
canvas.drawRect(0f, 0f, width, 1f, alphaPaint);
canvas.drawRect(0f, height - 1f, width, height, alphaPaint);
canvas.setBitmap(null);
return bitmap;
}
示例8: drawChild
import android.view.View; //导入方法依赖的package包/类
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result;
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int save = canvas.save(2);
if (!(!this.mCanSlide || lp.slideable || this.mSlideableView == null)) {
canvas.getClipBounds(this.mTmpRect);
if (isLayoutRtlSupport()) {
this.mTmpRect.left = Math.max(this.mTmpRect.left, this.mSlideableView.getRight());
} else {
this.mTmpRect.right = Math.min(this.mTmpRect.right, this.mSlideableView.getLeft());
}
canvas.clipRect(this.mTmpRect);
}
if (VERSION.SDK_INT >= 11) {
result = super.drawChild(canvas, child, drawingTime);
} else if (!lp.dimWhenOffset || this.mSlideOffset <= 0.0f) {
if (child.isDrawingCacheEnabled()) {
child.setDrawingCacheEnabled(false);
}
result = super.drawChild(canvas, child, drawingTime);
} else {
if (!child.isDrawingCacheEnabled()) {
child.setDrawingCacheEnabled(true);
}
Bitmap cache = child.getDrawingCache();
if (cache != null) {
canvas.drawBitmap(cache, (float) child.getLeft(), (float) child.getTop(), lp.dimPaint);
result = false;
} else {
Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache");
result = super.drawChild(canvas, child, drawingTime);
}
}
canvas.restoreToCount(save);
return result;
}
示例9: captureWithoutStatusBar
import android.view.View; //导入方法依赖的package包/类
/**
* 获取当前屏幕截图,不包含状态栏
*
* @param activity activity
* @return Bitmap
*/
public static Bitmap captureWithoutStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
int statusBarHeight = BarUtils.getStatusBarHeight(activity);
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
Bitmap ret = Bitmap.createBitmap(bmp, 0, statusBarHeight, dm.widthPixels, dm.heightPixels - statusBarHeight);
view.destroyDrawingCache();
return ret;
}
示例10: unExpandViews
import android.view.View; //导入方法依赖的package包/类
private void unExpandViews(boolean deletion) {
for (int i = 0;; i++) {
View v = getChildAt(i);
if (v == null) {
if (deletion) {
// HACK force update of mItemCount
int position = getFirstVisiblePosition();
int y = getChildAt(0).getTop();
setAdapter(getAdapter());
setSelectionFromTop(position, y);
// end hack
}
layoutChildren(); // force children to be recreated where needed
v = getChildAt(i);
if (v == null) {
break;
}
}
ViewGroup.LayoutParams params = v.getLayoutParams();
params.height = mItemHeightNormal;
v.setLayoutParams(params);
v.setVisibility(View.VISIBLE);
// Reset the drawing cache, the positions might have changed.
// We don't want the cache to be wrong.
v.setDrawingCacheEnabled(false);
}
}
示例11: snapShotWithStatusBar
import android.view.View; //导入方法依赖的package包/类
/**
* 获取当前屏幕截图,包含状态栏
*
* @param activity
* @return
*/
public static Bitmap snapShotWithStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
int width = getScreenWidth(activity);
int height = getScreenHeight(activity);
Bitmap bp = null;
bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
view.destroyDrawingCache();
return bp;
}
示例12: getView
import android.view.View; //导入方法依赖的package包/类
/**
* 获取点击的item的对应View,
* 因为点击的Item已经有了自己归属的父容器MyGridView,所有我们要是有一个ImageView来代替Item移动
*
* @param view
* @return
*/
private ImageView getView(View view) {
view.destroyDrawingCache();
view.setDrawingCacheEnabled(true);
Bitmap cache = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
ImageView iv = new ImageView(this);
iv.setImageBitmap(cache);
return iv;
}
示例13: of
import android.view.View; //导入方法依赖的package包/类
public static Bitmap of(View view, BlurFactor factor) {
view.setDrawingCacheEnabled(true);
view.destroyDrawingCache();
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
Bitmap cache = view.getDrawingCache();
Bitmap bitmap = of(view.getContext(), cache, factor);
cache.recycle();
return bitmap;
}
示例14: captureWithStatusBar
import android.view.View; //导入方法依赖的package包/类
/**
* 获取当前屏幕截图,包含状态栏
*
* @param activity activity
* @return Bitmap
*/
public static Bitmap captureWithStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
Bitmap ret = Bitmap.createBitmap(bmp, 0, 0, dm.widthPixels, dm.heightPixels);
view.destroyDrawingCache();
return ret;
}
示例15: getActivityBitmap
import android.view.View; //导入方法依赖的package包/类
public static Bitmap getActivityBitmap(Activity activity) {
View view = activity.getWindow().getDecorView().findViewById(android.R.id.content);
view.setDrawingCacheEnabled(true);
return view.getDrawingCache();
}