android - 有没有办法只重绘一个 View ?

标签 android

我有包含 4 个 ImageView 的 GroupView。

当我更改一个 View 的参数(例如重新缩放图像或旋转)时,这会导致重新绘制整个布局。

我想防止重绘整个布局,只想重绘特定的 View 。

最佳答案

当然可以。

myView.invalidate()

参见: https://developer.android.com/reference/android/view/View.html#invalidate()

Drawing is handled by walking the tree and recording the drawing commands of any View that needs to update. After this, the drawing commands of the entire tree are issued to screen, clipped to the newly damaged area.

The tree is largely recorded and drawn in order, with parents drawn before (i.e., behind) their children, with siblings drawn in the order they appear in the tree. If you set a background drawable for a View, then the View will draw it before calling back to its onDraw() method. The child drawing order can be overridden with custom child drawing order in a ViewGroup, and with setZ(float) custom Z values} set on Views.

To force a view to draw, call invalidate().

关于android - 有没有办法只重绘一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40889545/

相关文章:

android - [Android]如何在Fragment中为AlertDialog设置final

java - 试图将所有联系人放入 ListView 中?

android - 来自多个表的 SugarORM 查询?

android - View 的闪烁边框

android 将服务绑定(bind)到 Activity

java - 以编程方式将 RadioButton 的边距或填充添加到 RadioGroup 中

android - 当用户在 Google Maps v2 for Android API 上按下“我的位置中心”按钮时如何收到通知

android - 将 Jsoup 请求转换为 retrofit2

java - Android - 代码覆盖率测试错误

java - 发送可识别短信