辅助球的布局文件 floatball.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:Android="https://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<Button
android:id="@+id/float_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/selector_btn_assistive"
/>
</FrameLayout>
窗口菜单的布局文件floatmenu.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
android:id="@+id/menu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/transparent" >
<LinearLayout
android:layout_width="@dimen/size_dialog"
android:layout_height="@dimen/size_dialog"
android:layout_centerInParent="true"
android:background="@drawable/shape_background_assistivetouch"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/lay_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="4.0px"
android:visibility="visible" >
<TextView
android:id="@+id/btn_apps"
android:layout_centerInParent="true"
android:drawableTop="@drawable/selector_ic_apps"
android:text="@string/apps" />
<TextView
android:id="@+id/btn_home_screen"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:drawableTop="@drawable/selector_ic_home"
android:text="@string/home_screen" />
<TextView
android:id="@+id/btn_setting"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:drawableTop="@drawable/selector_ic_phone"
android:text="@string/setting" />
<TextView
android:id="@+id/btn_lock_screen"
android:layout_centerHorizontal="true"
android:drawableTop="@drawable/selector_ic_power_down"
android:text="@string/lock_screen" />
<TextView
android:id="@+id/btn_favor"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:drawableTop="@drawable/selector_ic_star"
android:text="@string/favor" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
package="com.tyd.floatball"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".util.MyApplication">
<activity
android:label="@string/app_name"
android:name=".ui.MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".service.TopFloatService"
android:enabled="true"
android:exported="true"
/>
</application>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
</manifest>
iPhone有个圆球辅助工具,它漂浮在你的手机屏幕(在任何APP之上),你可以将它移动到任何地方,它叫做AssistiveTouch,我的这个代码是仿AssistiveTouch实现的一个悬浮辅助球工具。
该实例我已经将源码整理打包,进行了上传,下面是资源的下载地址:
具体下载目录在 /2013年资料/5月/13日/仿iPhone的AssistiveTouch 悬浮辅助球工具