懸浮窗的實現(如360懸浮窗效果)

來源:互聯網
上載者:User

<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 

 

如有大家,不明白之處,盡情留言評價。。。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.