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


Java View.isDrawingCacheEnabled方法代码示例

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


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

示例1: 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:Louis19910615,项目名称:youkes_browser,代码行数:36,代码来源:ScreenShotUtil.java

示例2: getViewAsBitmap

import android.view.View; //导入方法依赖的package包/类
public static Bitmap getViewAsBitmap(View view){
    Bitmap bitmap = null;
    if(view.isDrawingCacheEnabled()){
        view.buildDrawingCache();
        bitmap = view.getDrawingCache();
    }else {
        view.setDrawingCacheEnabled(true);
        view.buildDrawingCache();
        bitmap = view.getDrawingCache();
        view.destroyDrawingCache();
        view.setDrawingCacheEnabled(false);
    }
    return bitmap;
}
 
开发者ID:vipulyaara,项目名称:betterHotels,代码行数:15,代码来源:ViewUtils.java

示例3: setupChild

import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (VERSION.SDK_INT >= 11) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
    if (needToMeasure) {
        int childWidthSpec;
        int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
        int lpWidth = p.width;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
        child.jumpDrawablesToCurrentState();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:65,代码来源:HListView.java

示例4: 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,项目名称:letv,代码行数:37,代码来源:SlidingPaneLayout.java

示例5: takeScreenShot

import android.view.View; //导入方法依赖的package包/类
@NonNull
public static Bitmap takeScreenShot(Window window) throws IOException {
    final View rootView = window.getDecorView().getRootView();
    final boolean drawingCacheEnabled = rootView.isDrawingCacheEnabled();
    rootView.setDrawingCacheEnabled(true);

    try {
        return Bitmap.createBitmap(rootView.getDrawingCache());
    } finally {
        rootView.setDrawingCacheEnabled(drawingCacheEnabled);
    }
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:13,代码来源:ScreenShotUtil.java

示例6: setupChild

import android.view.View; //导入方法依赖的package包/类
private void setupChild(View child, int position, int y, boolean flowDown, int childrenLeft,
                        boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    ViewGroup.LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, -2, 0);
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    p.scrappedFromPosition = position;
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (needToMeasure) {
        int childHeightSpec;
        int childWidthSpec = ViewGroup.getChildMeasureSpec(this.mWidthMeasureSpec, this
                .mListPadding.left + this.mListPadding.right, p.width);
        int lpHeight = p.height;
        if (lpHeight > 0) {
            childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
        } else {
            childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        onMeasureChild(child, position, childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childTop = flowDown ? y : y - h;
    if (needToMeasure) {
        onLayoutChild(child, position, childrenLeft, childTop, childrenLeft + w, childTop + h);
    } else {
        onOffsetChild(child, position, childrenLeft - child.getLeft(), childTop - child
                .getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:57,代码来源:PLA_ListView.java

示例7: drawChild

import android.view.View; //导入方法依赖的package包/类
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    final LayoutParams lp = (LayoutParams) child.getLayoutParams();
    boolean result;
    final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);

    if (mCanSlide && !lp.slideable && mSlideableView != null) {
        // Clip against the slider; no sense drawing what will immediately be covered.
        canvas.getClipBounds(mTmpRect);
        if (isLayoutRtlSupport()) {
            mTmpRect.left = Math.max(mTmpRect.left, mSlideableView.getRight());
        } else {
            mTmpRect.right = Math.min(mTmpRect.right, mSlideableView.getLeft());
        }
        canvas.clipRect(mTmpRect);
    }

    if (Build.VERSION.SDK_INT >= 11) { // HC
        result = super.drawChild(canvas, child, drawingTime);
    } else {
        if (lp.dimWhenOffset && mSlideOffset > 0) {
            if (!child.isDrawingCacheEnabled()) {
                child.setDrawingCacheEnabled(true);
            }
            final Bitmap cache = child.getDrawingCache();
            if (cache != null) {
                canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint);
                result = false;
            } else {
                Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache");
                result = super.drawChild(canvas, child, drawingTime);
            }
        } else {
            if (child.isDrawingCacheEnabled()) {
                child.setDrawingCacheEnabled(false);
            }
            result = super.drawChild(canvas, child, drawingTime);
        }
    }

    canvas.restoreToCount(save);

    return result;
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:45,代码来源:SideMenu.java


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