/Timeline-View

Android Timeline View is used to display views like Tracking of shipment/order, steppers etc.

Primary LanguageJavaApache License 2.0Apache-2.0

Timeline-View

Android Timeline View Library (Using RecyclerView) is simple implementation used to display view like Tracking of shipment/order, steppers etc.

Specs

Download

Badges/Featured In

Android Arsenal Android Gems AndroidDev Digest

Screenshots of Sample Application

Sample Application Apk

Screenshot

Screenshot

Quick Setup

1. Include library

Using Gradle

dependencies {
    compile 'com.github.vipulasri:timelineview:1.0.4'
}

Using Maven

<dependency>
    <groupId>com.github.vipulasri</groupId>
    <artifactId>timelineview</artifactId>
    <version>1.0.4</version>
    <type>pom</type>
</dependency>

Manual:

Manual - Using Android Studio:

  • Download the library folder and import to your root application folder. You can manually achieve this step with 3 steps:
    1. Paste the folder library into your application at the same level of your app, build and gradle folder
    2. Add to your settings.gradle file the following code line: "include ':app', ':timelineview'"
    3. Rebuild the project
  • File → Project Structure → in Modules section click on "app" → Click on tab "Dependecies" → Click on the green plus → Module Dependecy → Select ":library"
  • Done

What's New

See the project's Releases page for a list of versions with their changelogs.

If you Watch this repository, GitHub will send you an email every time I publish an update.

2. Usage

  • In XML Layout :
<com.github.vipulasri.timelineview.TimelineView
    android:id="@+id/time_marker"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:marker_size="20dp"
    app:line_size="2dp"
    app:line="@color/colorPrimary"/>
  • Configure using xml attributes or setters in code:

    Attribute Name Default Value Description
    app:marker="@drawable/marker" Green Colored Oval Drawable sets marker drawable
    app:marker_size="25dp" 25px sets marker size
    app:markerInCenter="false" true sets the marker in center of line if `true`
    app:line="@color/primarColor" N/A Compulsory Field - set line color
    app:line_size="2dp" 2px sets line width
    app:line_orientation="horizontal" vertical sets orientation of line ie `horizontal` or `vertical`
  • RecyclerView Holder : Your RecyclerViewHolder should have an extra paramenter in constructor i.e viewType from onCreateViewHolder. You would also have to call the method initLine(viewType) in constructor definition.

    public class TimeLineViewHolder extends RecyclerView.ViewHolder {
        public  TimelineView mTimelineView;

        public TimeLineViewHolder(View itemView, int viewType) {
            super(itemView);
            mTimelineView = (TimelineView) itemView.findViewById(R.id.time_marker);
            mTimelineView.initLine(viewType);
        }
    }
  • RecyclerView Adapter : override getItemViewType method in Adapter
    @Override
    public int getItemViewType(int position) {
        return TimelineView.getTimeLineViewType(position,getItemCount());
    }

And pass the viewType from onCreateViewHolder to its Holder.

    @Override
    public TimeLineViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_timeline, null);
        return new TimeLineViewHolder(view, viewType);
    }

For information : checkout sample app in repository.

Apps that use this library

If you're using this library in your app and you'd like to list it here, Please let me know via email or pull requests or issues.

License

Copyright 2017 Vipul Asri

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.