【发布时间】:2011-06-28 22:14:45
【问题描述】:
我正在使用 Android SDK 附带的 Hierarchy Viewer 工具进行一些测试。
我正在测试的Activity 具有以下 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:layout_alignParentTop="true"/>
<TextView android:id="@+id/slow_measure"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="Slow Measure"
android:layout_alignParentBottom="true"/>
<TextView android:id="@+id/slow_layout"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:text="Slow Layout"
android:layout_above="@id/slow_measure"/>
<com.test.SlowDrawView android:id="@+id/slow_draw"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:text="Slow Draw"
android:layout_above="@id/slow_layout"/>
</RelativeLayout>
SlowDrawView 扩展了 TextView,但我修改了 onDraw(),如下所示:
@Override
protected void onDraw(Canvas canvas) {
try {
Thread.sleep(3000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
super.onDraw(canvas);
}
当我在 hv 中检查这个 View 的绘制时间时,我注意到小于 3segs,这没有任何意义。
对为什么会发生这种情况有任何想法吗? 我还注意到在 android git repo 中有两个版本的 hv。有谁知道区别吗?
【问题讨论】: