有人知道在surfaceview上重叠移动图标的想法吗。它就像你窗口上的光标,但我需要它在安卓应用程序中。
我试着使用一个相对的ImageView,并不断更改它的位置,但主线程将是ANR。第二,我试着把它添加到画布上,但当图标移动时,它会有幽灵,因为我无法清除屏幕。如果我清除屏幕,整个视图将是黑色的。
有人有这种功能的经验吗?
已解决
修正了光标和背景颜色混合在一起的问题,所以我不需要另一个ImageView来适应。
在xml布局中使用FrameLayout环绕surfaceView。然后将您的图标添加到同一FrameLayout中。确保它们被放置在表面视图的下面,这样它们就会被画在上面。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView android:id="@+id/surfaceView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></SurfaceView>
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</FrameLayout>
尝试用图标或图像替换按钮。。