Android scrollview實(shí)現(xiàn)底部繼續(xù)拖動(dòng)查看圖文詳情
本文實(shí)例為大家分享了Android實(shí)現(xiàn)底部拖動(dòng)查看圖文詳情的具體代碼,供大家參考,具體內(nèi)容如下
一、效果圖
二、實(shí)現(xiàn)步驟
1.xml布局的實(shí)現(xiàn)/p>
<ScrollView android:id="@+id/mymyscrollview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/rejcdosjflk" android:background="#ffffff" android:scrollbars="none"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="60dp" android:orientation="vertical"> </LinearLayout> </ScrollView>
2.activity的實(shí)現(xiàn)
private ScrollView mScrollView; mScrollView = (ScrollView) findViewById(R.id.mymyscrollview); //調(diào)用方法 mScrollView.setOnTouchListener(new TouchListenerImpl()); private int scrollY; private int height; private int scrollViewMeasuredHeight; private class TouchListenerImpl implements View.OnTouchListener { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_MOVE: scrollY = view.getScrollY(); height = view.getHeight(); scrollViewMeasuredHeight = mScrollView.getChildAt(0) .getMeasuredHeight(); break; case MotionEvent.ACTION_UP: System.out.println("scrollY=" + scrollY); System.out.println("height=" + height); System.out.println("scrollViewMeasuredHeight=" + scrollViewMeasuredHeight); if (scrollY == 0) { System.out.println("滑動(dòng)到了頂端 view.getScrollY()=" + scrollY); } else if ((scrollY + height) >= scrollViewMeasuredHeight) { Message msg = new Message(); msg.what = 0; mHandlerht.sendMessage(msg); } else { System.out.println("滑動(dòng) height=" + height); } // 復(fù)位 scrollY = 0; height = 0; scrollViewMeasuredHeight = 0; break; default: break; } return false; } } private Handler mHandlerht = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case 0: // 跳轉(zhuǎn) Intent intentcll = new Intent(); intentcll.setClass(BDDetialActivityCll.this, CSProductDetailsCll.class); intentcll.putExtra("product", ncspbean); startActivity(intentcll); break; default: break; } } };
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android制作一個(gè)錨點(diǎn)定位的ScrollView
- Android 滑動(dòng)Scrollview標(biāo)題欄漸變效果(仿京東toolbar)
- Android使用ScrollView實(shí)現(xiàn)滾動(dòng)效果
- Android scrollview如何監(jiān)聽滑動(dòng)狀態(tài)
- Android解決ScrollView下嵌套ListView和GridView中內(nèi)容顯示不全的問題
- Android使用HorizontalScrollView實(shí)現(xiàn)水平滾動(dòng)
- Android ScrollView實(shí)現(xiàn)橫向和豎向拖動(dòng)回彈效果
- Android中ScrollView監(jiān)聽滑動(dòng)距離案例講解
相關(guān)文章
Android實(shí)現(xiàn)按鈕點(diǎn)擊事件的三種方法總結(jié)
Button是程序用于和用戶進(jìn)行交互的一個(gè)重要控件。既然有Button,那肯定有onClick方法,下面就教大家三種實(shí)現(xiàn)點(diǎn)擊事件的方法,感興趣的可以了解一下2022-04-04Android 編輯頭像功能簡單實(shí)現(xiàn)實(shí)例(圖片選取,裁剪)
這篇文章主要介紹了Android 編輯頭像功能簡單實(shí)現(xiàn)實(shí)例(圖片選取,裁剪),非常具有實(shí)用價(jià)值,需要的朋友可以參考下2017-06-06Android實(shí)現(xiàn)讀寫JSON數(shù)據(jù)的方法
這篇文章主要介紹了Android實(shí)現(xiàn)讀寫JSON數(shù)據(jù)的方法,以完整實(shí)例形式分析了Android解析及生成json數(shù)據(jù)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android開發(fā)中Toast顯示消息的方法小結(jié)
這篇文章主要介紹了Android開發(fā)中Toast顯示消息的方法,結(jié)合實(shí)例形式總結(jié)分析了Toast的功能、創(chuàng)建Toast對(duì)象及調(diào)用相關(guān)函數(shù)顯示消息提示框的操作技巧,需要的朋友可以參考下2016-10-10Android仿微信右上角點(diǎn)擊加號(hào)彈出PopupWindow
這篇文章主要為大家詳細(xì)介紹了Android仿微信右上角點(diǎn)擊加號(hào)彈出PopupWindow,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04