<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"="http://schemas.android.com/tools"="wrap_content"="wrap_content"=".MainActivity"="horizontal" > <="@+id/icon"="wrap_content"="wrap_content"="@drawable/rekoo" /> <="@+id/floats"="wrap_content"="wrap_content"="horizontal"="@drawable/settings_bg_right"="2dp"="gone" > <="@+id/btn1"="wrap_content"="wrap_content"="vertical"="2dp" > <="wrap_content"="wrap_content"="@drawable/settings_bbs_pressed" /> <="wrap_content"="wrap_content"="論壇"="@android:color/white" /> </LinearLayout> <="@+id/btn2"="wrap_content"="wrap_content"="10dp"="vertical" > <="wrap_content"="wrap_content"="@drawable/settings_bind_phone_pressed" /> <="wrap_content"="wrap_content"="電話"="@android:color/white" /> </LinearLayout> <="@+id/btn3"="wrap_content"="wrap_content"="10dp"="vertical" > <="wrap_content"="wrap_content"="@drawable/settings_service_pressed" /> <="wrap_content"="wrap_content"="關閉"="@android:color/white" /> </LinearLayout> </LinearLayout></LinearLayout>
MainActivity Activity WindowManager windowManager = WindowManager.LayoutParams windowManagerParams = = LayoutInflater.from().inflate(R.layout.floating, ===== windowManager = windowManagerParams = windowManagerParams.type = LayoutParams.TYPE_PHONE; windowManagerParams.format = PixelFormat.RGBA_8888; windowManagerParams.flags =| windowManagerParams.gravity = Gravity.LEFT | windowManagerParams.x = 0= 80 windowManagerParams.width == Display display = screenWith = screenHeight ="screenWith="+screenWith+",screenHeight="+ Rect frame = statusBarHeight ="狀態列高度:"+ x == event.getRawY() - statusBarHeight; "x="+x+",y="+ MotionEvent.ACTION_DOWN: mTouchX ====",mTouchX=" + mTouchX + ",mTouchY=" + MotionEvent.ACTION_MOVE: MotionEvent.ACTION_UP: left = x-(left <= screenWith/2){ x = { x = mTouchX + mTouchX = mTouchY = 0 ((x - mStartX) < 5 && (y - mStartY) < 5 = () (x -= () (y -"wp.x="+windowManagerParams.x+",wp.y="+ (floats.getVisibility() ==,"親,我是論壇!", 2,"親,我是手機驗證!", 2
如有大家,不明白之處,盡情留言評價。。。