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


Java View.invalidate方法代码示例

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


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

示例1: onTouch

import android.view.View; //导入方法依赖的package包/类
@Override
public boolean onTouch(View view, MotionEvent event) {
    if (view instanceof ImageView) {
        ImageView imageView = (ImageView) view;

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                rect = new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
                imageView.setColorFilter(FILTERED_GREY, PorterDuff.Mode.SRC_ATOP);
                view.invalidate();
                break;
            }
            case MotionEvent.ACTION_MOVE:
                // if move inside button do nothing, otherwise clear filter
                if(rect.contains(view.getLeft() + (int) event.getX(), view.getTop() + (int) event.getY()))
                    break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL: // Action call when button is inside scrollable view
                imageView.clearColorFilter();
                view.invalidate();
        }
    }
    return false;
}
 
开发者ID:thanhbinh84,项目名称:clickable-image-view,代码行数:25,代码来源:EffectTouchListener.java

示例2: onTouch

import android.view.View; //导入方法依赖的package包/类
/**
 * If a custom background images is specified for the button, then it will lose the pressed
 * and disabled image effects; no visual feedback.
 * The approach below is to provide a visual feedback if and only if an image is assigned
 * to the button. In this situation, we overlay a gray background when pressed and
 * release when not-pressed.
 */
@Override
public boolean onTouch(View view, MotionEvent me)
{
    //NOTE: We ALWAYS return false because we want to indicate that this listener has not
    //been consumed. Using this approach, other listeners (e.g. OnClick) can process as normal.
    if (me.getAction() == MotionEvent.ACTION_DOWN) {
        //button pressed, provide visual feedback AND return false
        if (ShowFeedback()) {
           view.getBackground().setAlpha(70); // translucent
           view.invalidate();
        }
        TouchDown();
    } else if (me.getAction() == MotionEvent.ACTION_UP ||
        me.getAction() == MotionEvent.ACTION_CANCEL) {
        //button released, set button back to normal AND return false
        if (ShowFeedback()) {
           view.getBackground().setAlpha(255); // opaque
           view.invalidate();
        }
        TouchUp();
    }

    return false;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:32,代码来源:ButtonBase.java

示例3: invalidateAfterUpdate

import android.view.View; //导入方法依赖的package包/类
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View)view.getParent();
    if (parent == null) {
        return;
    }

    view.setAnimation(this);

    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);

    parent.invalidate(
            (int) Math.floor(after.left),
            (int) Math.floor(after.top),
            (int) Math.ceil(after.right),
            (int) Math.ceil(after.bottom));
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:23,代码来源:AnimatorProxy.java

示例4: refresh

import android.view.View; //导入方法依赖的package包/类
/**
 * call this method to refresh the graph with a given matrix
 *
 * @param newMatrix
 * @return
 */
public Matrix refresh(Matrix newMatrix, View chart, boolean invalidate) {

    mMatrixTouch.set(newMatrix);

    // make sure scale and translation are within their bounds
    limitTransAndScale(mMatrixTouch, mContentRect);

    if (invalidate)
        chart.invalidate();

    newMatrix.set(mMatrixTouch);
    return newMatrix;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ViewPortHandler.java

示例5: onTouch

import android.view.View; //导入方法依赖的package包/类
public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction()) {
        case 0:
            this.lastX = (int) event.getRawX();
            this.lastY = (int) event.getRawY();
            break;
        case 2:
            int dx = ((int) event.getRawX()) - this.lastX;
            int dy = ((int) event.getRawY()) - this.lastY;
            int left = v.getLeft() + dx;
            int top = v.getTop() + dy;
            int right = v.getRight() + dx;
            int bottom = v.getBottom() + dy;
            this.lastX = (int) event.getRawX();
            this.lastY = (int) event.getRawY();
            if (left < 0) {
                right = v.getWidth();
            }
            if (right > this.screenWidth) {
                right = this.screenWidth;
                left = right - v.getWidth();
            }
            if (top < 0) {
                bottom = v.getHeight();
            }
            if (bottom > this.screenHeight) {
                bottom = this.screenHeight;
                top = bottom - v.getHeight();
            }
            v.layout(left, top, right, bottom);
            v.invalidate();
            break;
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:36,代码来源:FilterFigureFragment.java

示例6: reapplyItemInfo

import android.view.View; //导入方法依赖的package包/类
/**
 * Applies the item info if it is same as what the view is pointing to currently.
 */
public void reapplyItemInfo(final ItemInfo info) {
    if (getTag() == info) {
        FastBitmapDrawable.State prevState = FastBitmapDrawable.State.NORMAL;
        if (mIcon instanceof FastBitmapDrawable) {
            prevState = ((FastBitmapDrawable) mIcon).getCurrentState();
        }
        mIconLoadRequest = null;
        mDisableRelayout = true;

        if (info instanceof AppInfo) {
            applyFromApplicationInfo((AppInfo) info);
        } else if (info instanceof ShortcutInfo) {
            applyFromShortcutInfo((ShortcutInfo) info,
                    LauncherAppState.getInstance().getIconCache());
            if ((info.rank < FolderIcon.NUM_ITEMS_IN_PREVIEW) && (info.container >= 0)) {
                View folderIcon =
                        mLauncher.getWorkspace().getHomescreenIconByItemId(info.container);
                if (folderIcon != null) {
                    folderIcon.invalidate();
                }
            }
        } else if (info instanceof PackageItemInfo) {
            applyFromPackageItemInfo((PackageItemInfo) info);
        }

        // If we are reapplying over an old icon, then we should update the new icon to the same
        // state as the old icon
        if (mIcon instanceof FastBitmapDrawable) {
            ((FastBitmapDrawable) mIcon).setState(prevState);
        }

        mDisableRelayout = false;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:38,代码来源:BubbleTextView.java

示例7: recursiveInvalidate

import android.view.View; //导入方法依赖的package包/类
/**
 * Invalidates a view and all of its descendants.
 */
private static void recursiveInvalidate(View view) {
    view.invalidate();
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        int childCount = group.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = group.getChildAt(i);
            if (child.getVisibility() == View.VISIBLE) {
                recursiveInvalidate(child);
            }
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:ViewUtils.java

示例8: updateAllConnectorLocations

import android.view.View; //导入方法依赖的package包/类
/**
 * Force every {@link BlockView} in this group to recalculate the locations of its
 * connections; used to return the views and models to a consistent state after a drag.
 */
public void updateAllConnectorLocations() {
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        BlockView childBlockView = (BlockView) child;
        childBlockView.updateConnectorLocations();
        child.invalidate();
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:14,代码来源:BlockGroup.java

示例9: setAlpha

import android.view.View; //导入方法依赖的package包/类
public void setAlpha(float alpha) {
    if (mAlpha != alpha) {
        mAlpha = alpha;
        View view = mView.get();
        if (view != null) {
            view.invalidate();
        }
    }
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:10,代码来源:AnimatorProxy.java

示例10: setWavePos

import android.view.View; //导入方法依赖的package包/类
public void setWavePos(int pos) {
    boolean changed = (offset != pos);
    offset = pos;
    View v = viewRef.get();
    if (v != null && changed)
        v.invalidate();
}
 
开发者ID:NickKJ,项目名称:WavesView,代码行数:8,代码来源:DoubleWavesShaderView.java

示例11: setForeground

import android.view.View; //导入方法依赖的package包/类
/**
 * Supply a Drawable that is to be rendered on top of all of the child
 * views in the frame layout.  Any padding in the Drawable will be taken
 * into account by ensuring that the children are inset to be placed
 * inside of the padding area.
 *
 * @param drawable The Drawable to be drawn on top of the children.
 */
public void setForeground(View view, Drawable drawable) {
    if (view != null) {
        if (mForeground != drawable) {
            if (mForeground != null) {
                mForeground.setCallback(null);
                view.unscheduleDrawable(mForeground);
            }

            mForeground = drawable;

            if (drawable != null) {
                view.setWillNotDraw(false);
                drawable.setCallback(view);
                if (drawable.isStateful()) {
                    drawable.setState(view.getDrawableState());
                }
                if (mForegroundGravity == Gravity.FILL) {
                    Rect padding = new Rect();
                    drawable.getPadding(padding);
                }

                //update bounds
                updateBounds(view, drawable);//added by song
            } else {
                view.setWillNotDraw(true);
            }
            view.requestLayout();
            view.invalidate();
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:40,代码来源:ForegroundDelegate.java

示例12: setBackgroundDrawable

import android.view.View; //导入方法依赖的package包/类
public static void setBackgroundDrawable(View view, Drawable drawable) {
  view.setBackgroundDrawable(drawable);
  view.invalidate();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:5,代码来源:ViewUtil.java

示例13: makeChildTransfromer

import android.view.View; //导入方法依赖的package包/类
/**
     * 对 bitmap 进行伪 3d 变换
     *
     * @param child
     * @param position
     * @param offset
     */
    private void makeChildTransfromer(View child, int position, float offset) {
        child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());

        float scale = 0;
        float scaleX = 0;
        scale = 1 - Math.abs(offset) * 0.25f;
        scaleX = 1 - Math.abs(offset) * 0.15f;

        // 延x轴移动的距离应该根据center图片决定
        float translateY = 0;

        final int originalChildHeight = (int) (mChildHeight - mChildHeight
                * reflectHeightFraction - reflectGap);

        final float originalChildHeightScale = (float) originalChildHeight / child.getHeight();

        final float childHeightScale = originalChildHeightScale * scale;
        final float childWidthScale = originalChildHeightScale * scaleX;


        final int centerChildHeight = (int) (child.getHeight() * originalChildHeightScale);

        topSpace = (mHeight-centerChildHeight)/2;
//        float baseDis = dip2px(getContext(),24);
        baseDis = centerChildHeight/4.9f;

        translateY = (mHeight-centerChildHeight)/2- baseDis *offset*-1;

        //根据offset 算出透明度
        float alpha = 254 - Math.abs(offset) * STANDARD_ALPHA;

        child.setAlpha(0);
        if (alpha < 0) {
            alpha = 0;
        } else if (alpha > 254) {
            alpha = 254;
        }
        child.setAlpha(alpha / 254.0f);

        ObjectAnimator anim1 = ObjectAnimator.ofFloat(child, "scaleX", 1.0f, childWidthScale);
        ObjectAnimator anim2 = ObjectAnimator.ofFloat(child, "scaleY", 1.0f, childHeightScale);
        AnimatorSet animSet = new AnimatorSet();
        animSet.setDuration(0);
        //两个动画同时执行
        animSet.playTogether(anim1, anim2);
        child.setPivotX(child.getWidth()/2);
        child.setPivotY(child.getHeight() / 2);
        //显示的调用invalidate
        child.invalidate();
        animSet.setTarget(child);
        animSet.start();

        child.setTranslationX(mChildTranslateX);
        child.setTranslationY(translateY);

    }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:64,代码来源:CoverFlowView.java

示例14: setLabelVisual

import android.view.View; //导入方法依赖的package包/类
public void setLabelVisual(View view, boolean visual) {
    if (this.visual != visual) {
        this.visual = visual;
        view.invalidate();
    }
}
 
开发者ID:open-android,项目名称:labelview,代码行数:7,代码来源:LabelViewHelper.java

示例15: setLabelTextColor

import android.view.View; //导入方法依赖的package包/类
public void setLabelTextColor(View view, int textColor) {
    if (this.textColor != textColor) {
        this.textColor = textColor;
        view.invalidate();
    }
}
 
开发者ID:open-android,项目名称:labelview,代码行数:7,代码来源:LabelViewHelper.java


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