您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本文实例为大家分享了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; } } };
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持亿速云。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。