用加速度计绘制java图形
我已经在Java中使用加速计实现了pin输入方法来解锁安卓智能手机,现在我想通过使用acclerometer绘制图案来更新它。谁能帮帮我,因为我对此一无所知。 提前谢谢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:orientation="vertical"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:id="@+id/main_view"
安卓:background="#ff00ff00">
<Button
安卓:id="@+id/button1"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignParentLeft="true"
安卓:layout_alignParentTop="true"
安卓:layout_marginLeft="21dp"
安卓:layout_marginTop="28dp"
安卓:text=""
安卓:background="@drawable/red_button"/>
<Button
安卓:id="@+id/button4"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/button1"
安卓:layout_centerVertical="true"
安卓:text=""
安卓:background="@drawable/blue_button" />
<Button
安卓:id="@+id/button6"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignLeft="@+id/button4"
安卓:layout_below="@+id/button4"
安卓:layout_marginLeft="26dp"
安卓:layout_marginTop="88dp"
安卓:text=""
安卓:background="@drawable/rep_button"/>
<Button
安卓:id="@+id/button2"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_above="@+id/button5"
安卓:layout_centerHorizontal="true"
安卓:layout_marginBottom="46dp"
安卓:background="@drawable/yellow_button" />
<Button
安卓:id="@+id/button3"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignBaseline="@+id/button1"
安卓:layout_alignBottom="@+id/button1"
安卓:layout_toRightOf="@+id/button2"
安卓:background="@drawable/black_button" />
<Button
安卓:id="@+id/button5"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_above="@+id/button6"
安卓:layout_alignLeft="@+id/button7"
安卓:background="@drawable/pink_button" />
<Button
安卓:id="@+id/button7"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_alignBaseline="@+id/button6"
安卓:layout_alignBottom="@+id/button6"
安卓:layout_toRightOf="@+id/button2"
安卓:background="@drawable/org_button" />
</RelativeLayout>
# 1 楼答案
以下是我发现的一些可以帮助您开始的开放源代码:
以下是主要活动:
这是BallView课程:
您可以将框架布局与以下代码结合使用:
这将生成一个蓝球,该蓝球将对设备倾斜做出相应的响应。可以通过对球的位置进行采样来添加多边形线机制,并相应地在这些连接点上绘制连接线,从而创建看起来像连续平滑线的多段线