欢迎来到代码驿站!

Android代码

当前位置:首页 > 移动开发 > Android代码

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

时间:2020-11-02 17:18:39|栏目:Android代码|点击:

本文实例为大家分享了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;
  }
 }


};

上一篇:Android ImageView Src 和Background 区别

栏    目:Android代码

下一篇:android隐式意图激活自定义界面和系统应用界面的实例

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

本文地址:http://www.codeinn.net/misctech/18338.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有