1

私が取り組んでいるアプリは、画面全体に表示される1つの大きなカスタムビューで構成されています。カスタムビューの両側の中央に、描画されたオブジェクトをその方向に移動するために使用できるボタンを1つ配置しました。カスタムビューをカメラの「ファインダー」と考えてください。ユーザーが4つの側面すべてにボタンがあるファインダーをパンできるようにしたいと思います。

ボタンは完全に機能しますが、ボタンを押すと、下のカスタムビューで多くの再描画が行われ(1回ではなく4回の再描画)、UIがかなり遅れます。

ボタンのアニメーションが原因でカスタムビューの再描画を停止する方法はありますか?

明らかな何かが欠けている場合は許してください。

助けてくれてありがとう...Androidロック!!!

XMLレイアウト:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <com.app.CustomView
    android:id="@+id/CustomView" android:layout_above="@+id/menuButton" android:layout_height="fill_parent" android:layout_width="fill_parent"/>
    <Button android:layout_height="wrap_content" android:layout_below="@+id/CustomView" android:layout_width="wrap_content" android:layout_alignRight="@+id/CustomView" android:id="@+id/toolsButton" android:text="Tools" android:textSize="24sp"></Button>
    <Button android:layout_height="wrap_content" android:id="@+id/outButton" android:text="-" android:textSize="30sp" android:layout_toLeftOf="@+id/inButton" android:layout_alignTop="@+id/inButton" android:layout_width="40sp"></Button>
    <Button android:layout_height="wrap_content" android:layout_alignRight="@+id/CustomView" android:layout_alignBottom="@+id/CustomView" android:text="+" android:textSize="30sp" android:id="@+id/inButton" android:layout_width="wrap_content"></Button>
    <Button android:layout_alignTop="@+id/CustomView" android:layout_centerHorizontal="true" android:layout_height="40sp" android:layout_width="60sp" android:text="^" android:id="@+id/upButton"></Button>
    <Button android:layout_alignBottom="@+id/CustomView" android:layout_centerHorizontal="true" android:text="v" android:layout_height="40sp" android:layout_width="60sp" android:id="@+id/downButton"></Button>
    <Button android:layout_alignRight="@+id/CustomView" android:text="&gt;" android:id="@+id/rightButton" android:layout_height="60sp" android:layout_width="40sp" android:layout_centerVertical="true"></Button>
    <Button android:id="@+id/leftButton" android:text="&lt;" android:layout_height="60sp" android:layout_width="40sp" android:layout_centerVertical="true"></Button>
    <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignLeft="@+id/CustomView" android:id="@+id/menuButton" android:textSize="24sp" android:text="Functions" android:layout_alignParentBottom="true"></Button>

</RelativeLayout>
4

2 に答える 2

0

ボタンがカスタムビューの一部であるのはなぜですか?レイアウトがすべてのボタンとカスタムビューで構成されるように、それらをアクティビティレイアウトの一部にしてみませんか?

onDrawメソッドを呼び出すとUIスレッドがブロックされる場合は、カスタムビューの実装方法をさらに最適化/再考する必要があるため、これで問題が完全に解決されるとは限りません。

于 2011-01-29T19:11:51.860 に答える
0

私は実際に計算を正確にしすぎていて、貧弱なドロイドを一生懸命働いていたことがわかりました。今ではすべてがスムーズに描画されます。

于 2011-01-30T04:07:53.003 に答える