Use Fragment to dock the top of the Listview, and fragmentlistview

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.