当前位置: 移动技术网 > IT编程>移动开发>Android > Android scrollview实现底部继续拖动查看图文详情

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

2019年07月29日  | 移动技术网IT编程  | 我要评论

52522,爱上千金美眉全集,火秀刷枪精灵

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

一、效果图

二、实现步骤

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;
  }
 }


};

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网