Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在视图类的 onMeasure() 中对长度和高度大小进行了一些编辑,制作了一个自定义的图像视图。我已经在我的 Main Activity 的onCreate方法中设置了这个内容,但是这些更改不适用于我的 imageview。有什么解决方案可以在onResume方法中重绘我的 imageview 吗?因此,我在视图类中对 onMeasure() 所做的所有更改都将适用。
谁能帮我这个?非常感谢 !
从 View 类派生的每个类都有invalidate() 和 postInvalidate() 方法。如果 invalidate() 被调用,它会告诉系统当前视图已经改变并且应该尽快重绘。
您可以在 onResume() 方法上执行以下操作:
@Override protected void onResume() { super.onResume(); imageView.invalidate(); }