android view怎么刷新,Android开发 View的UI刷新Invalidate和postInvalidate

/*** Mark the area defined by dirty as needing to be drawn. If the view is

* visible, {@link#onDraw(android.graphics.Canvas)} will be called at some

* point in the future.

*

* This must be called from a UI thread. To call from a non-UI thread, call

* {@link#postInvalidate()}.

*

* WARNING: In API 19 and below, this method may be destructive to

* {@codedirty}.

*

*@paramdirty the rectangle representing the bounds of the dirty region

*

*@deprecatedThe switch to hardware accelerated rendering in API 14 reduced

* the importance of the dirty rectangle. In API 21 the given rectangle is

* ignored entirely in favor of an internally-calculated area instead.

* Because of this, clients are encouraged to just call {@link#invalidate()}.*/@Deprecatedpublic voidinvalidate(Rect dirty) {final int scrollX =mScrollX;final int scrollY =mScrollY;

invalidateInternal(dirty.left- scrollX, dirty.top -scrollY,

dirty.right- scrollX, dirty.bottom - scrollY, true, false);

}/*** Mark the area defined by the rect (l,t,r,b) as needing to be drawn. The

* coordinates of the dirty rect are relative to the view. If the view is

* visible, {@link#onDraw(android.graphics.Canvas)} will be called at some

* point in the future.

*

* This must be called from a UI thread. To call from a non-UI thread, call

* {@link#postInvalidate()}.

*

*@paraml the left position of the dirty region

*@paramt the top position of the dirty region

*@paramr the right position of the dirty region

*@paramb the bottom position of the dirty region

*

*@deprecatedThe switch to hardware accelerated rendering in API 14 reduced

* the importance of the dirty rectangle. In API 21 the given rectangle is

* ignored entirely in favor of an internally-calculated area instead.

* Because of this, clients are encouraged to just call {@link#invalidate()}.*/@Deprecatedpublic void invalidate(int l, int t, int r, intb) {final int scrollX =mScrollX;final int scrollY =mScrollY;

invalidateInternal(l- scrollX, t - scrollY, r - scrollX, b - scrollY, true, false);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值