<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

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

          作者: 時間:2016-09-12 來源:網絡 收藏

          1.onCreate中添加GestureDetector mGestureDetector;

          本文引用地址:http://www.ex-cimer.com/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方法,根據e1、e2的坐標差判斷左右滑動,同時在里面寫滑動的效果。

          View Code

          工程下載:GuideViewTest.rar

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

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

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

          View Code

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

          View Code

          4、數據適配器和頁面切換事件監(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、加入權限

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

          View Code

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

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



          關鍵詞: Android 手勢識別

          評論


          相關推薦

          技術專區(qū)

          關閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();