最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開(kāi)發(fā)之ListView的head消失頁(yè)面導(dǎo)航欄的漸變出現(xiàn)和隱藏

 更新時(shí)間:2016年11月24日 13:55:22   作者:凸尾巴小狼  
這篇文章主要介紹了Android開(kāi)發(fā)之ListView的head消失頁(yè)面導(dǎo)航欄的漸變出現(xiàn)和隱藏的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

1.Fragment頁(yè)面xml布局:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ptr="http://schemas.android.com/apk/res-auto"
tools:context=".fragment.home.HomeStoreFragment"
>
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/lv_home_store_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
ptr:ptrDrawable="@drawable/default_ptr_flip"
ptr:ptrAnimationStyle="flip"
/>
<!--top 搜索欄-->
<LinearLayout
android:id="@+id/ll_top_search"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/zuti"
android:visibility="invisible"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/shape_edit_cornor"
android:gravity="center"
>
<ImageView
android:id="@+id/iv_search_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/icon_navbar_search"
android:layout_marginRight="5dp"
/>
<EditText
android:id="@+id/et_store_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="輸入商家或商品名"
android:textColorHint="@color/shenhui"
android:background="@null"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

2.主要代碼:

private boolean isFlingScroll;
private View headView;
private PullToRefreshListView lvHomeStore;
initView(){
lvHomeStore = (PullToRefreshListView) view.findViewById(R.id.lv_home_store_list);
lvHomeStore.setMode(PullToRefreshBase.Mode.BOTH);
ListView listView = lvHomeStore.getRefreshableView();
headView = initHeadView();
AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);//這句要加上去
headView.setLayoutParams(layoutParams);
listView.addHeaderView(headView);
lvHomeStore.setAdapter(adapter);
lvHomeStore.setOnScrollListener(this);
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == SCROLL_STATE_FLING) {//手指離開(kāi)手機(jī)界面,Listview還在滑動(dòng)
isFlingScroll = true;
} else if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {//手指在界面上滾動(dòng)的情況
isFlingScroll = false;
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
showSearchBarShow();
}
private void showSearchBarShow() {
int headBottomToParentTop = headView.getHeight() + headView.getTop();
Log.d("homeStore", "headView.getHeight(): " + headView.getHeight());
Log.d("homeStore", "headView.getTop(): " + headView.getTop());
Log.d("homeStore", "headBottomToParentTop: " + headBottomToParentTop);
if (!isFlingScroll) {//手指在界面滑動(dòng)的情況
int height = layoutSearch.getHeight();
Log.d("homeStore", "height: " + height);
if (headBottomToParentTop > height) {
layoutSearch.setVisibility(View.INVISIBLE);
} else if (headBottomToParentTop <= height) {//緩慢滑動(dòng),這部分代碼工作正常,快速滑動(dòng),里面的數(shù)據(jù)就跟不上節(jié)奏了。
float alpha = (height - headBottomToParentTop) * 1f / height;
Log.d("homeStore", "alpha: " + alpha);
layoutSearch.setAlpha(alpha);
layoutSearch.setVisibility(View.VISIBLE);
}
if (!headView.isShown()){//解決快速滑動(dòng),上部分代碼不能正常工作的問(wèn)題。
layoutSearch.setAlpha(1);
layoutSearch.setVisibility(View.VISIBLE);
}
} else {//手指離開(kāi),listview還在滑動(dòng),一般情況是列表快速滑動(dòng),這種情況直接設(shè)置導(dǎo)航欄的可見(jiàn)性
if (!headView.isShown()) {
if (!layoutSearch.isShown()){
layoutSearch.setVisibility(View.VISIBLE);
layoutSearch.setAlpha(1);
}
} else {
if (layoutSearch.isShown()){
layoutSearch.setVisibility(View.INVISIBLE);
}
}
}
}

以上所述是小編給大家介紹的Android開(kāi)發(fā)之ListView的head消失頁(yè)面導(dǎo)航欄的漸變出現(xiàn)和隱藏,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android實(shí)現(xiàn)360手機(jī)助手底部的動(dòng)畫(huà)菜單

    Android實(shí)現(xiàn)360手機(jī)助手底部的動(dòng)畫(huà)菜單

    這篇文章給大家分享了利用Android實(shí)現(xiàn)360手機(jī)助手底部的動(dòng)畫(huà)菜單效果,文中給出了實(shí)例代碼,這樣對(duì)大家的學(xué)習(xí)或者理解更有幫助,有需要的朋友們下面來(lái)一起看看吧。
    2016-10-10
  • Kotlin?Dispatchers協(xié)程調(diào)度器源碼深入分析

    Kotlin?Dispatchers協(xié)程調(diào)度器源碼深入分析

    Kotlin協(xié)程不是什么空中閣樓,Kotlin源代碼會(huì)被編譯成class字節(jié)碼文件,最終會(huì)運(yùn)行到虛擬機(jī)中。所以從本質(zhì)上講,Kotlin和Java是類似的,都是可以編譯產(chǎn)生class的語(yǔ)言,但最終還是會(huì)受到虛擬機(jī)的限制,它們的代碼最終會(huì)在虛擬機(jī)上的某個(gè)線程上被執(zhí)行
    2022-11-11
  • android文字描邊功能的實(shí)現(xiàn)

    android文字描邊功能的實(shí)現(xiàn)

    本文介紹的是android文字描邊功能的實(shí)現(xiàn),文字描邊的功能在開(kāi)發(fā)中還是聽(tīng)實(shí)用的,有需要的可以參考學(xué)習(xí)
    2016-07-07
  • Android 中解決Viewpage調(diào)用notifyDataSetChanged()時(shí)界面無(wú)刷新的問(wèn)題

    Android 中解決Viewpage調(diào)用notifyDataSetChanged()時(shí)界面無(wú)刷新的問(wèn)題

    這篇文章主要介紹了Android 中解決Viewpage調(diào)用notifyDataSetChanged()時(shí)界面無(wú)刷新的問(wèn)題的相關(guān)資料,這里提供相應(yīng)的解決辦法,需要的朋友可以參考下
    2017-08-08
  • Android開(kāi)發(fā)應(yīng)用中Broadcast Receiver組件詳解

    Android開(kāi)發(fā)應(yīng)用中Broadcast Receiver組件詳解

    本篇文章主要介紹了Android開(kāi)發(fā)應(yīng)用中Broadcast Receiver組件詳解,想要學(xué)習(xí)的同學(xué)可以了解一下。
    2016-11-11
  • Android中巧妙的實(shí)現(xiàn)緩存詳解

    Android中巧妙的實(shí)現(xiàn)緩存詳解

    采用緩存,可以進(jìn)一步大大緩解數(shù)據(jù)交互的壓力,有的時(shí)候?yàn)榱丝焖俨樵儠?huì)被多次調(diào)用的數(shù)據(jù),或者構(gòu)建比較廢時(shí)的實(shí)例,我們一般使用緩存的方法。無(wú)論大型或小型應(yīng)用,靈活的緩存可以說(shuō)不僅大大減輕了服務(wù)器的壓力,而且因?yàn)楦焖俚挠脩趔w驗(yàn)而方便了用戶。下面來(lái)一起看看吧。
    2016-11-11
  • Android?Notification使用教程詳解

    Android?Notification使用教程詳解

    這篇文章主要介紹了Android?Notification使用,通知的使用的內(nèi)容還是比較多的,此篇文章將會(huì)盡可能詳細(xì)的介紹Notification的內(nèi)容,需要的朋友可以參考下
    2022-07-07
  • 分析Android 11.0Settings源碼之主界面加載

    分析Android 11.0Settings源碼之主界面加載

    這篇文章主要介紹了分析Android 11.0Settings源碼之主界面加載,對(duì)Android源碼感興趣的同學(xué),可以著重看一下
    2021-04-04
  • Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法

    Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法

    這篇文章主要給大家介紹了關(guān)于在Android N 7.0中報(bào)錯(cuò):android.os.FileUriExposedException的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧
    2018-05-05
  • Android nativePollOnce函數(shù)解析

    Android nativePollOnce函數(shù)解析

    這篇文章主要介紹了Android nativePollOnce函數(shù)解析的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下
    2021-03-03

最新評(píng)論

吉木乃县| 德兴市| 昌吉市| 岢岚县| 宁明县| 阿克苏市| 谢通门县| 武冈市| 宁晋县| 镇宁| 大洼县| 青神县| 错那县| 苍梧县| 囊谦县| 中牟县| 东乌珠穆沁旗| 安塞县| 彰武县| 文昌市| 漳浦县| 鹤庆县| 临城县| 会泽县| 湖南省| 贵溪市| 蒲城县| 五常市| 江津市| 栾川县| 德保县| 紫阳县| 麻江县| 临猗县| 昌邑市| 绥阳县| 本溪| 鄂伦春自治旗| 河北区| 南城县| 若尔盖县|