StickyTimeLine
StickyTimeLine is timeline view for android.
What's New in 0.0.17? :tada:
- New Feature isSticky
How to Use
Gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.sangcomz:StickyTimeLine:v0.0.17'
}
Usage
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="xyz.sangcomz.stickytimeline.MainActivity">
<xyz.sangcomz.stickytimelineview.TimeLineRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
MainActivity.kt
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val recyclerView: TimeLineRecyclerView = findViewById(R.id.recycler_view)
//Currently only LinearLayoutManager is supported.
recyclerView.layoutManager = LinearLayoutManager(this,
LinearLayoutManager.VERTICAL,
false)
//Get data
val singerList = getSingerList()
//Add RecyclerSectionItemDecoration.SectionCallback
recyclerView.addItemDecoration(getSectionCallback(singerList))
//Set Adapter
recyclerView.adapter = SingerAdapter(layoutInflater,
singerList,
R.layout.recycler_row)
}
//Get data method
private fun getSingerList(): List<Singer> = SingerRepo().singerList
//Get SectionCallback method
private fun getSectionCallback(singerList: List<Singer>): RecyclerSectionItemDecoration.SectionCallback {
return object : RecyclerSectionItemDecoration.SectionCallback {
//In your data, implement a method to determine if this is a section.
override fun isSection(position: Int): Boolean =
singerList[position].debuted != singerList[position - 1].debuted
//Implement a method that returns a SectionHeader.
override fun getSectionHeader(position: Int): SectionInfo? =
SectionInfo(singerList[position].debuted, singerList[position].group)
}
}
}
caution
- Currently only LinearLayoutManager is supported.
recycler_row.xml
<?xml version="1.0" encoding="utf-8"?>
<!--Don't set margin value in the parent view-->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/full_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</android.support.v7.widget.CardView>
caution
- Don't set margin value in the parent view.
attribute
Method Name | Description | Default Value |
---|---|---|
sectionBackgroundColor | To change section section background color | #f9f9f9 |
sectionTitleTextColor | To change section title color | #414fca |
sectionSubTitleTextColor | To change section sub title color | #d16767 |
sectionLineColor | To change line color in timeline | #51ae45 |
sectionCircleColor | To change circle color in timeline | #51ae45 |
sectionStrokeColor | To change circle stroke color in timeline | #f9f9f9 |
sectionTitleTextSize | To change section title text size | 14sp |
sectionSubTitleTextSize | To change section sub title text size | 12sp |
sectionLineWidth | To change line width in timeline | 4dp |
:new: isSticky | To change Sticky functionality in the Timeline | true |
Result Screen
Project Name | Result Screen |
---|---|
Sample | |
AlleysMap |