本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
示例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();
}
}
}
示例12: setBackgroundDrawable
import android.view.View; //导入方法依赖的package包/类
public static void setBackgroundDrawable(View view, Drawable drawable) {
view.setBackgroundDrawable(drawable);
view.invalidate();
}
示例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);
}
示例14: setLabelVisual
import android.view.View; //导入方法依赖的package包/类
public void setLabelVisual(View view, boolean visual) {
if (this.visual != visual) {
this.visual = visual;
view.invalidate();
}
}
示例15: setLabelTextColor
import android.view.View; //导入方法依赖的package包/类
public void setLabelTextColor(View view, int textColor) {
if (this.textColor != textColor) {
this.textColor = textColor;
view.invalidate();
}
}