Use Fragment to dock the top of the Listview, and fragmentlistview
After working with xiechengfa for a few days, android has learned a lot. Here we will summarize the technical points. Reference address: click here. I was very forced to work. After half a year of playing android, I did not dig deep into the technology, which caused a lot of slow responses. I have to study it in depth !!!
Less code. Or more. As follows:
Using Fragment to dock the top of the Listview, refer
StickyListHeaders
Reference: http://blog.csdn.net/xiechengfa/article/details/39005775
1. Demo.
2. automatic failover of two fragment (switch data and
Listview)
3. slide to the top and no longer slide !!
4. The navigation menu on the top is automatically removed. The button on the Tab is displayed.
There are two technical points. This layout is implemented using FrameLayout. There is a hierarchy in it.
The top layer is the fragment (that is, the top layer of listview ==> headerViewLayout ==> toptitle (outer layer)
Is the largest coverage in the innermost layer. This is a technical point. Be considerate!
There are many technical points to explore. However, the results are satisfied first. In the future, we will gradually explore technical points.
@Overridepublic void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {float headerMoveDistance = ViewHelper.getTranslationY(headerView);if (headerMoveDistance <= -headerContent.getHeight()) {iv_tabMore.setVisibility(View.VISIBLE);iv_tabBack.setVisibility(View.VISIBLE);ll_top.setVisibility(View.INVISIBLE);} else {iv_tabMore.setVisibility(View.INVISIBLE);iv_tabBack.setVisibility(View.INVISIBLE);ll_top.setVisibility(View.VISIBLE);}int scrollY = getScrollY(view);System.out.println("****************onScroll scrollY:" + scrollY + ",mMinHeaderTranslation:"+ header_logo.getHeight() + ",end:" + Math.max(-scrollY, header_logo.getHeight()));ViewHelper.setTranslationY(headerView, Math.max(-scrollY, -headerContent.getHeight()));}
This code is used to determine how much you slide. Is it at the top ?? What if it reaches the top ??? What should I do with ViewHelper? So very good!
Demo: Click the open link and click here.
Zookeeper