Android編程實(shí)現(xiàn)Gallery中每次滑動(dòng)只顯示一頁的方法
本文實(shí)例講述了Android編程實(shí)現(xiàn)Gallery中每次滑動(dòng)只顯示一頁的方法。分享給大家供大家參考,具體如下:
import android.content.Context; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; import android.widget.Gallery; public class DetialGallery extends Gallery { public DetialGallery(Context context ,AttributeSet attrSet) { super(context,attrSet); // TODO Auto-generated constructor stub } private boolean isScrollingLeft(MotionEvent e1, MotionEvent e2) { return e2.getX() > e1.getX(); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // TODO Auto-generated method stub // return super.onFling(e1, e2, 0, velocityY); //方法一:只去除翻頁慣性 // return false; //方法二:只去除翻頁慣性 注:沒有被注釋掉的代碼實(shí)現(xiàn)了開始說的2種效果。 int kEvent; if(isScrollingLeft(e1, e2)){ //Check if scrolling left kEvent = KeyEvent.KEYCODE_DPAD_LEFT; } else{ //Otherwise scrolling right kEvent = KeyEvent.KEYCODE_DPAD_RIGHT; } onKeyDown(kEvent, null); return true; } }
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
- Android程序開發(fā)之Listview下拉刷新上拉(滑動(dòng)分頁)加載更多
- Android實(shí)現(xiàn)基于滑動(dòng)的SQLite數(shù)據(jù)分頁加載技術(shù)(附demo源碼下載)
- Android App中使用ViewPager實(shí)現(xiàn)滑動(dòng)分頁的要點(diǎn)解析
- Android實(shí)現(xiàn)listview動(dòng)態(tài)加載數(shù)據(jù)分頁的兩種方法
- Android應(yīng)用中利用ViewPager實(shí)現(xiàn)多頁面滑動(dòng)切換效果示例
- Android仿今日頭條滑動(dòng)頁面導(dǎo)航效果
- Android編程實(shí)現(xiàn)ViewPager多頁面滑動(dòng)切換及動(dòng)畫效果的方法
- 解析Android中實(shí)現(xiàn)滑動(dòng)翻頁之ViewFlipper的使用詳解
- Android中實(shí)現(xiàn)多行、水平滾動(dòng)的分頁的Gridview實(shí)例源碼
- Android提高之SQLite分頁表格實(shí)現(xiàn)方法
- Android實(shí)現(xiàn)ListView分頁自動(dòng)加載數(shù)據(jù)的方法
- Android滑動(dòng)動(dòng)態(tài)分頁實(shí)現(xiàn)方法
相關(guān)文章
如何給Flutter界面切換實(shí)現(xiàn)點(diǎn)特效
這篇文章主要給大家介紹了關(guān)于如何給Flutter界面切換實(shí)現(xiàn)點(diǎn)特效的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09Android動(dòng)畫之漸變動(dòng)畫(Tween Animation)詳解 (漸變、縮放、位移、旋轉(zhuǎn))
這篇文章主要介紹了Android動(dòng)畫之漸變動(dòng)畫(Tween Animation)用法,結(jié)合實(shí)例形式詳細(xì)分析了Android漸變動(dòng)畫Tween Animation實(shí)現(xiàn)漸變,縮放,位移,旋轉(zhuǎn)等技巧,需要的朋友可以參考下2016-01-01Android中SharedPreference詳解及簡單實(shí)例
這篇文章主要介紹了 Android中SharedPreference詳解及簡單實(shí)例的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-09-09Android仿簡書動(dòng)態(tài)searchview搜索欄效果
這篇文章主要為大家詳細(xì)介紹了Android仿簡書動(dòng)態(tài)searchview效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06Android 開機(jī)應(yīng)用掃描相關(guān)總結(jié)
本篇文章只是作為指南引導(dǎo)去看PkMS,不會(huì)貼大段代碼進(jìn)行分析,更多是基于方法分析實(shí)現(xiàn)的邏輯,另外就是代碼是基于Android 11,與Android 10之前代碼有比較大的差別。2021-05-05Android ScrollView顯示到底部或任意位置實(shí)現(xiàn)代碼
這篇文章主要介紹了 Android ScrollView顯示到底部或任意位置實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-02-02Android BLE 藍(lán)牙開發(fā)之實(shí)現(xiàn)掃碼槍基于BLESSED開發(fā)
這篇文章主要介紹了Android BLE 藍(lán)牙開發(fā)之實(shí)現(xiàn)掃碼槍基于BLESSED開發(fā),示例代碼介紹了第三方庫BLESSED for Android的使用,需要的朋友可以參考下2022-03-03