欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android scrollview实现底部继续拖动查看图文详情

程序员文章站 2022-03-08 17:17:41
本文实例为大家分享了android实现底部拖动查看图文详情的具体代码,供大家参考,具体内容如下 一、效果图 二、实现步骤 1.xml布局的实现/p>...

本文实例为大家分享了android实现底部拖动查看图文详情的具体代码,供大家参考,具体内容如下

一、效果图

Android scrollview实现底部继续拖动查看图文详情

二、实现步骤

1.xml布局的实现/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的实现

private scrollview mscrollview;
mscrollview = (scrollview) findviewbyid(r.id.mymyscrollview);
//调用方法
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("滑动到了顶端 view.getscrolly()=" + scrolly);
    } else if ((scrolly + height) >= scrollviewmeasuredheight) {
     message msg = new message();
     msg.what = 0;
     mhandlerht.sendmessage(msg);
    } else {
     system.out.println("滑动 height=" + height);
    }
    // 复位
    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:
    // 跳转
    intent intentcll = new intent();
    intentcll.setclass(bddetialactivitycll.this,
      csproductdetailscll.class);
    intentcll.putextra("product", ncspbean);
    startactivity(intentcll);
    break;
   default:
    break;
  }
 }


};

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。