如何理解该机器人完成绘制一个看法? [英] How to understand that android finished drawing a view?
本文介绍了如何理解该机器人完成绘制一个看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
当有活动完成绘制本身?
我要当一个视图完成其图纸就知道了,这可能吗?我如何可以理解,如果机器人完成绘制一个视图或不?
I want to know when a view completes its drawing, is that possible? How can I understand if android finished drawing a view or not?
推荐答案
一ViewTreeObserver添加到它。
Add a ViewTreeObserver to it.
样,
TextView pagerView1=new TextView(this);
ViewTreeObserver textViewTreeObserver=pagerView1.getViewTreeObserver();
textViewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
//Do your operations here.
pagerView1.removeGlobalOnLayoutListener(this);
}
});
这是一次特定的被绘制完成它被调用监听器。所以,我已使用的TextView。同样,你可以利用你做任何的看法。和里面onGlobalLayout(),你可以做你的code。
This is a Listener which gets called once that particular gets drawn completely. So I have made it use for TextView. Similarly you can make use of any view you do. And inside onGlobalLayout() you can do your code.
这篇关于如何理解该机器人完成绘制一个看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文