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

二、實(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;
}
}
};
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android制作一個(gè)錨點(diǎn)定位的ScrollView
- Android 滑動(dòng)Scrollview標(biāo)題欄漸變效果(仿京東toolbar)
- Android使用ScrollView實(shí)現(xiàn)滾動(dòng)效果
- Android scrollview如何監(jiān)聽滑動(dòng)狀態(tài)
- Android解決ScrollView下嵌套ListView和GridView中內(nèi)容顯示不全的問題
- Android使用HorizontalScrollView實(shí)現(xiàn)水平滾動(dòng)
- Android ScrollView實(shí)現(xiàn)橫向和豎向拖動(dòng)回彈效果
- Android中ScrollView監(jiān)聽滑動(dòng)距離案例講解
相關(guān)文章
android中soap協(xié)議使用(ksoap調(diào)用webservice)
kSOAP是如何調(diào)用ebservice的呢,首先要使用SoapObject,這是一個(gè)高度抽象化的類,完成SOAP調(diào)用??梢哉{(diào)用它的addProperty方法填寫要調(diào)用的webservice方法的參數(shù)2014-02-02
Android中AutoCompleteTextView與TextWatcher結(jié)合小實(shí)例
這篇文章主要為大家詳細(xì)介紹了Android中AutoCompleteTextView與TextWatcher結(jié)合的小實(shí)例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
android實(shí)現(xiàn)簡(jiǎn)單計(jì)算器功能
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)簡(jiǎn)單計(jì)算器功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09
如何通過Android Stduio來編寫一個(gè)完整的天氣預(yù)報(bào)APP
這篇文章主要介紹了通過Android Stduio來編寫一個(gè)天氣預(yù)報(bào)APP,具體的實(shí)現(xiàn)是通過調(diào)用天氣預(yù)報(bào)接口來獲得天氣數(shù)據(jù),再將查詢的天氣信息存儲(chǔ)在SQLiteDatabase中,界面則用LIstView和GridView來搭建2021-08-08
Android開發(fā)自學(xué)筆記(三):APP布局上
這篇文章主要介紹了Android開發(fā)自學(xué)筆記(三):APP布局上,本文講解了添加ViewGroup、添加ViewGroup、定義string內(nèi)容、添加Button、運(yùn)行程序查看效果等內(nèi)容,需要的朋友可以參考下2015-04-04
快速關(guān)閉android studio的自動(dòng)保存功能教程
這篇文章主要介紹了快速關(guān)閉android studio的自動(dòng)保存功能教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-04-04

