2011-01-29 7 views
1

私が取り組んでいるアプリケーションは、画面をいっぱいにする大きなカスタムビューで構成されています。私は、その方向に描画オブジェクトを移動するために使用できるカスタムビューの各辺の中央に1つのボタンを配置しました。カスタムビューをカメラの「ファインダ」と考えて、4面すべてのボタンでビューファインダをパンすることができるようにしたいと思います。ビューの上にボタンを描画する最も効率的な方法は?

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

ボタンのアニメーションのために再描画されないようにカスタムビューを停止する方法はありますか?

明らかに何か不足している場合は私を許してください。

事前にお手数をおかけします... Android rocks !!!

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> 

答えて

0

私は実際に私の計算をあまり正確にしていて、貧弱なドロイドをあまりにも難しくしていたことがわかりました。すべてがスムーズに描画されます。

0

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

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

+0

私が不明な場合は、ボタンはレイアウトの一部であり、カスタム表示ではなくカスタム表示の上に表示されます。 –

+0

ボタンを押したときにカスタム表示を無効にしていますか? – user432209

+0

私はですが、私のログでは、カスタム表示が目的の1の代わりに4回再描画されていることがわかります。ボタンを押して表示を再描画させないようにしたいのですが、 。 –

関連する問題