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


Java View.setDrawingCacheEnabled方法代码示例

本文整理汇总了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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:BlurTask.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:ChannelFragmentAdapter.java

示例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;

}
 
开发者ID:ChenTianSaber,项目名称:DailyZhiHu,代码行数:26,代码来源:ScreenUtils.java

示例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;
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:22,代码来源:Screenshot.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:15,代码来源:XCCycleViewPager.java

示例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;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:21,代码来源:ScreenUtils.java

示例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;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:36,代码来源:ScreenShotUtil.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:SlidingPaneLayout.java

示例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;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:19,代码来源:ScreenUtils.java

示例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);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:28,代码来源:TouchInterceptor.java

示例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;

}
 
开发者ID:gaolhjy,项目名称:cniao5,代码行数:20,代码来源:ScreenUtils.java

示例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;
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:17,代码来源:ColumnActivity.java

示例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;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:10,代码来源:Blur.java

示例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;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:18,代码来源:ScreenUtils.java

示例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();
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:6,代码来源:ViewUtils.java


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