中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > Android三種左右滑動效果 手勢識別

        Android三種左右滑動效果 手勢識別

        作者: 時間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

        1.onCreate中添加GestureDetector mGestureDetector;

        本文引用地址:http://www.antipu.com.cn/article/201609/303740.htm

        //監(jiān)聽手勢事件

        mGestureDetector = new GestureDetector(this, onGestureListener);

        2.//實現(xiàn)處理事件

        OnGestureListener onGestureListener = new OnGestureListener() {

        //添加未實現(xiàn)的方法

        };

        3.重寫onTouch事件

        //交由手勢探測接口處理觸摸事件

        public boolean onTouchEvent(MotionEvent event) {

        return mGestureDetector.onTouchEvent(event);

        }

        左右滑動效果1、在xml中定義ViewFlipper控件;

        2、重寫onTouchEvent方法,用于捕獲Touch事件

        View Code

        3、寫push_left_in.xml、push_left_out.xml、push_right_in.xml、push_right_out.xml文件,用于滑動時的效果顯現(xiàn);

        4、在Activity中定義OnGestureListener,重寫onFling方法,根據(jù)e1、e2的坐標差判斷左右滑動,同時在里面寫滑動的效果。

        View Code

        工程下載:GuideViewTest.rar

        來自:http://www.cnblogs.com/hanyonglu/archive/2012/02/13/2349827.html

        左右滑動指引效果1、加入android-support-v4.jar,關(guān)于android-support-v4.jar的詳細信息,大家可以訪問google官方網(wǎng)站:http://developer.android.com/sdk/compatibility-library.html;

        2、XML中,用FrameLayout完成布局,放入ViewPager和指引圖標

        View Code

        3、將頁面布局加入View的列表中,有幾個布局頁面就有幾個圓點圖片,通過for循環(huán)設(shè)置圓點圖片的布局;

        View Code

        4、數(shù)據(jù)適配器和頁面切換事件監(jiān)聽器

        5、在指引頁面更改事件監(jiān)聽器(GuidePageChangeListener)中要確保在切換頁面時下面的圓點圖片也跟著改變

        View Code

        工程下載:MyFlip.rar

        來自:http://www.cnblogs.com/hanyonglu/archive/2012/04/07/2435589.html

        漸顯按鈕的左右滑動效果1、XML中,定義ViewFlipper控件,在里面加入多個頁面布局,也可以用代碼ViewFlipper的addView方法;

        2、寫push_left_in.xml、push_left_out.xml、push_right_in.xml、push_right_out.xml文件;

        3、加入權(quán)限

        4、在Activity中,初始化左右懸浮按鈕,創(chuàng)建左右按鈕,并設(shè)置監(jiān)聽事件(替換圖片);

        View Code

        5、重寫onTouchEvent事件,用于觸發(fā)顯示和隱藏懸浮按鈕事件(MotionEvent.ACTION_DOWN和MotionEvent.ACTION_UP);

        6、利用線程,控制懸浮按鈕的透明度(Alpha和invalidate)



        關(guān)鍵詞: Android 手勢識別

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉