5

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);
}

Viewhv でこれの描画時間を確認すると、3 セグ未満であることがわかりましたが、これは意味がありません。

なぜこれが起こっているのかについてのアイデアはありますか?また、Android git リポジトリには 2 つのバージョンの hv があることにも気付きました。誰でも違いを知っていますか?

4

1 に答える 1