Android native Toolbar on steroids
SuperToolbar
Android native Toolbar on steroids.
Specs
Some key features are:
- Animate the toolbar elevation when scrolling.
- Center toolbar title
- Light title font
Also, it has been written 100% in Kotlin. ❤️
Download
This library is available in jitpack, so you need to add this repository to your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.andrefrsousa:SuperToolbar:{latest_version}'
}
Sample Project
We have a sample project in Kotlin that demonstrates the lib usages here.
Usage
It is recommended to check the sample project to get a complete understanding of all the features offered by the library.
In order to show the toolbar elevation you just need to call:
fun setElevationVisibility(show: Boolean)
If what to have the same effect found in Google Messages app for example, you to add a scroll listener to your RecyclerView or ScrollView.
An on the callback of the listener you use the method above.
Here is an example:
myRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
toolbar.setElevationVisibility(recyclerView.canScrollVertically(-1))
}
})
Customization
The are a group of general properties that you can define. These properties will be applied to all the SuperBottomSheet in your project.
// The duration of the elevation animation. By default is 250 miliseconds.
<attr name="superToolbar_animationDuration" format="integer"/>
// If you want to show the toolbar elevation when created. By default is false.
<attr name="superToolbar_showElevationAtStart" format="boolean"/>
// Center the toolbar title. By default is false.
<attr name="superToolbar_centerTitle" format="boolean"/>
// Use a light font as the toolbar title. Default is false.
<attr name="superToolbar_useLightFont" format="boolean"/>