我正在开发的应用程序包含一个填满屏幕的大型自定义视图。我在自定义视图的每一侧的中心放置了一个按钮,可用于在该方向上移动绘制的对象。将自定义视图视为相机的“取景器”,我希望用户能够使用所有四个侧面的按钮来平移取景器。
这些按钮工作得很好,但是当一个按钮被按下时,下面的自定义视图会经历大量的重绘(4 次重绘而不是 1 次),并且 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=">" android:id="@+id/rightButton" android:layout_height="60sp" android:layout_width="40sp" android:layout_centerVertical="true"></Button>
<Button android:id="@+id/leftButton" android:text="<" 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>