當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。