PagedHeadListView


Source link: https://github.com/JorgeCastilloPrz/PagedHeadListView

PagedHeadListView Android Library


[![Android Arsenal]( http://img.shields.io/badge/Android%20Arsenal-PagedHeadListView-blue.svg?style=flat)](http://android-arsenal.com/details/1/816)

Details

If you are looking for a listview with a paged header this is the dependency you are looking for. With PagedHeadListView you will be able to set your own fragments as new pages for the header, and a brand new indicator will be added automatically. You can play with all the custom attributes provided with the library to set indicator colors and position, ViewPager drag animation, and touch behaviour for the header view. PagedHeadListView supports API 11 - Android SDK 3.0 (HoneyComb) as minimum.

This lib brings a custom ListView class called PagedHeadListView to the final user. Use it to integrate the component in your own Android application. You will not need to create your own code with FragmentStatePagerAdapter or ViewPager by yourself for creating this cool user experience, as the library does the boring work for you.

Custom Attributes

This android library allows you to customize the following properties. Feel free to combine them to create your cool user interfaces:

  • pagedheadlistview:headerHeight: Dimen resources allowed.
  • pagedheadlistview:disableVerticalTouchOnHeader: Set it to true if you want the header to not be affected by verticall ListView scrolling.
  • pagedheadlistview:indicatorBgColor: Color resource for indicator background.
  • pagedheadlistview:indicatorColor: Color resource for indicator view.
  • pagedheadlistview:indicatorType: Type for the indicator. Types allowed are: topAligned, bottomAligned, and none. If you set the value to none, no indicator will be included.
  • pagedheadlistview:pageTransformer: You can set it to depth, zoomout, rotate, scale, flip, or accordion for using one of the stated ViewPager drag animations.

You can cutomize your own pageTransformer by extending ViewPager.PageTransformer native Android class and by adding it to the PagedHeadListView using the following method:

mPagedHeadListView.setHeaderPageTransformer(boolean reverseDrawingOrder, ViewPager.PageTransformer customPageTransformer);

Usage

In order to make it work, you will need to use PagedHeadListView class into your Android code. Please, don't forget to add the aditional xmlns:pagedheadlistview="http://schemas.android.com/apk/res-auto" namespace to it.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:pagedheadlistview="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<com.jorgecastilloprz.pagedheadlistview.PagedHeadListView

android:id="@+id/pagedHeadListView"

android:layout_width="match_parent"

android:layout_height="match_parent"

pagedheadlistview:headerHeight="@dimen/header_height"

pagedheadlistview:indicatorType="bottomAligned"

pagedheadlistview:disableVerticalTouchOnHeader="true"

pagedheadlistview:indicatorBgColor="@color/material_green"

pagedheadlistview:indicatorColor="@color/material_light_green" />  </RelativeLayout>

In your java code, use PagedHeadListView like this:

mPagedHeadList = (PagedHeadListView) rootView.findViewById(R.id.pagedHeadListView);
  mPagedHeadList.addFragmentToHeader(new FirstHeaderFragment());
 mPagedHeadList.addFragmentToHeader(new SecondHeaderFragment());
 mPagedHeadList.addFragmentToHeader(new ThirdHeaderFragment());
 mPagedHeadList.addFragmentToHeader(new FourthHeaderFragment());
 mPagedHeadList.addFragmentToHeader(new FifthHeaderFragment());
  mPagedHeadList.setHeaderOffScreenPageLimit(4);
 mPagedHeadList.setHeaderPageTransformer(PageTransformerTypes.FLIP);
  ArrayList<String> mockItemList = new ArrayList<String>();
  for (int i = 0; i < 50; i++)
  mockItemList.add(getResources().getString(R.string.mock_item) + " " + (i+1));
  MockListAdapter mockListAdapter = new MockListAdapter(getActivity(), R.layout.mock_list_item, mockItemList);
 mPagedHeadList.setAdapter(mockListAdapter);

For being able to listen to header page change events, use setOnHeaderPageChangeListener which needs a ViewPager.OnPageChangeListener item as an argument.

Following methods are avaiable to setup the pager programatically:

//Types vaiable: DEPTH, ZOOMOUT, ROTATE, SCALE, FLIP, ACCORDION. mPagedHeadListView.setHeaderPageTransformer(PageTransformerTypes pageTransformerType);
  //This is a mapping for normal setPageTransformer from Android support ViewPager. mPagedHeadListView.setHeaderPageTransformer(boolean reverseDrawingOrder, ViewPager.PageTransformer customPageTransformer);
  //Dynamic mode to set header's view height. (Always in pixels) mPagedHeadListView.setHeaderHeight(500);
 mPagedHeadListView.setHeaderHeight(getResources().getDimensionPixelSize(R.dimen.header_height_test));
  //For the user to be able to listen for header ViewPager events. mPagedHeadListView.setOnHeaderPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener);
  mPagedHeadListView.setHeaderOffScreenPageLimit(int offScreenPageLimit);
  mPagedHeadListView.setIndicatorBgColor(int indicatorBgColor);
 mPagedHeadListView.setIndicatorColor(int indicatorColor);
  //If you want to disable vertical touch on header programatically. mPagedHeadListView.disableVerticalTouchOnHeader();
  mPagedHeadList.setIndicatorBgColor(getResources().getColor(R.color.material_green));
 mPagedHeadList.setIndicatorColor(getResources().getColor(R.color.material_light_green));

Import PagedHeadListView dependency

Add the next code to your build.gradle project dependencies:

dependencies {

  compile 'com.github.jorgecastilloprz:pagedheadlistview:1.0.0@aar' 
}

Set the mavenCentral repo into the external build.gradle:

buildscript {

  repositories {

mavenCentral()
  
}

  dependencies {

classpath 'com.android.tools.build:gradle:0.12.+'
  
}
 
}
  allprojects {

  repositories {

mavenCentral()
  
}
 
}

If you are using Maven, use the following code:

<dependency>
<groupId>com.github.jorgecastilloprz</groupId>
<artifactId>pagedheadlistview</artifactId>
<version>1.0.0</version>
<type>aar</type> </dependency>

TODO - AT WORK

  • Give the users the possibility to extend AbstractPagedHeadIndicator class to develop their own indicators. A new setter will be added for it when i get sure that it is fully supported.

Developer

License

Copyright 2014 Jorge Castillo PĂ©rez  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

With CalculatorInputView you can add functionality to a calculation EDITTEXT.

A tag cloud component for Android.

Get the weather data you need right into your android app in an easy and efficient way.

A simple to use library addressing the lack of support for Speed dial transitions in Design Support Library.

Android Library for Setting a View via Fluent Interface.

Small and lightweight extensions to RecycerView.Adpter which adds missing ListView and GridView features to RecyclerView.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes