The Category_headerview can be realized by the page of the American Group App homepage

Source: Internet
Author: User


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/F7/wKioL1WNYcGCAWC_AAB0m_mGCis903.jpg "title=" Meituan_main_header01.png "alt=" Wkiol1wnycgcawc_aab0m_mgcis903.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/FB/wKiom1WNYATg_d-bAACTRz9BN0s370.jpg "title=" Meituan_main_header02.png "alt=" Wkiom1wnyatg_d-baactrz9bn0s370.jpg "/>

One. Main implementation Features:

Custom indicator, slide the page to switch page content, indicator follow changes;

Two. To achieve a step:

1. Custom Viewpagerindicator

①: Defines three brushes of different colors

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/F7/wKioL1WNZaqzeD2OAAEa2uIYizc765.jpg "title=" Meituan_main_header implementation of 01.png "alt=" Wkiol1wnzaqzed2oaaea2uiyizc765.jpg "/>

②: Draw three static circles on the canvas

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/F8/wKioL1WNZ2eQtgvNAACtmRlHL9s882.jpg "title=" Meituan_main_header implementation of 02.png "alt=" Wkiol1wnz2eqtgvnaactmrlhl9s882.jpg "/>

③: Change the CX value to center the indicator

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/F8/wKioL1WNZ_TRgE3lAACmKo9sIs8701.jpg "title=" Meituan_main_header03.png "alt=" Wkiol1wnz_trge3laacmko9sis8701.jpg "/>

④: Set the Move method, when moving to the last, no longer move

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/FB/wKiom1WNZ07g_qKGAADCm0o23d0589.jpg "title=" Meituan_main_header04.png "alt=" Wkiom1wnz07g_qkgaadcm0o23d0589.jpg "/>

2. Implementing Fragment Additions

①: New blank Main_header_category,viewpager and indicator siblings, such as

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/FB/wKiom1WNaDzxUj0lAADuWHX9jig536.jpg "title=" Meituan_main_header05.png "alt=" Wkiom1wnadzxuj0laaduwhx9jig536.jpg "/>

②: New fragment category01 for layout:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/FB/wKiom1WNag2jYftKAADmLRSZOJ0948.jpg "title=" Meituan_main_header06.png "alt=" Wkiom1wnag2jyftkaadmlrszoj0948.jpg "/>

③: Set different data sources based on page numbers in Categoryfragment

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/F8/wKioL1WNbwfQsBAZAAG15-zua0c094.jpg "title=" Meituan_main_header07.png "alt=" Wkiol1wnbwfqsbazaag15-zua0c094.jpg "/>

Pay special attention to the drawable data source in TextView to set this:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/F8/wKioL1WNb57gdWXPAAEFYMnwZyg202.jpg "title=" Meituan_main_header08.png "alt=" Wkiol1wnb57gdwxpaaefymnwzyg202.jpg "/>

④: Initializes the Headerview and its contained viewpage and indicator in the fragment where the home page is located

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/F8/wKioL1WNcIXAcjyZAAFU8amiVO0271.jpg "title=" Meituan_main_header09.png "alt=" Wkiol1wncixacjyzaafu8amivo0271.jpg "/>

⑤: Set the Pagerchangerlistener of the Headerview, set its adapter so that it switches the page data source according to the pagerposition, thereby altering the content

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/FB/wKiom1WNb2ah6wDIAAHuh2i6J3g188.jpg "title=" Meituan_main_header10.png "alt=" Wkiom1wnb2ah6wdiaahuh2i6j3g188.jpg "/>

3.ListView Add Headerview

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/F8/wKioL1WNcpHQFExzAAL0EmeZTI0897.jpg "style=" float: none; "title=" Meituan_main_header11.png "alt=" Wkiol1wncphqfexzaal0emezti0897.jpg "/>

Final home multiple headerview effects such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/FB/wKiom1WNcNWjMsP-AAFrprdIZmk920.jpg "style=" float: none; "title=" Meituan_main_header12.png "alt=" Wkiom1wncnwjmsp-aafrprdizmk920.jpg "/>


This article is from the "Fool cc" blog, please be sure to keep this source http://1137907860.blog.51cto.com/10452906/1666097

The Category_headerview can be realized by the page of the American Group App homepage

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.