2.act..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Android scrollview實(shí)現(xiàn)底部繼續(xù)拖動(dòng)查看圖文詳情

發(fā)布時(shí)間:2020-10-26 09:37:54 來源:腳本之家 閱讀:155 作者:沒心沒肺沒網(wǎng)名 欄目:移動(dòng)開發(fā)

本文實(shí)例為大家分享了Android實(shí)現(xiàn)底部拖動(dòng)查看圖文詳情的具體代碼,供大家參考,具體內(nèi)容如下

一、效果圖

Android scrollview實(shí)現(xiàn)底部繼續(xù)拖動(dòng)查看圖文詳情

二、實(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í)有所幫助,也希望大家多多支持億速云。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI