SubtitleCollapsingToolbarLayout
Standard CollapsingToolbarLayout with subtitle support. Using internal components of support design library allows it to behave similarly to its sibling CollapsingToolbarLayout, while also ensuring minimum library size.
Download
This library follows Android's support library revisions.
repositories {
google()
jcenter()
}
dependencies {
compile 'com.hendraanggrian:collapsingtoolbarlayout-subtitle:27.1.0'
}
Older versions:
- 27.0.1
- 26.1.0
Usage
Treat SubtitleCollapsingToolbarLayout
just like a regular CollapsingToolbarLayout
.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.SubtitleCollapsingToolbarLayout
android:id="@+id/subtitlecollapsingtoolbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:subtitle="Papua, Indonesia"
app:title="Raja Ampat">
<!-- collapsing toolbar content goes here -->
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.SubtitleCollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<!-- content goes here -->
</android.support.design.widget.CoordinatorLayout>
Attributes
Attribute | Description | Default value/behavior |
---|---|---|
subtitle |
subtitle text | disabled |
collapsedSubtitleTextAppearance |
text appearance of subtitle when collapsed | TextAppearance.AppCompat.Widget.ActionBar.Subtitle |
expandedSubtitleTextAppearance |
text appearance of subtitle when expanded | TextAppearance.AppCompat.Headline |
fixMenuPadding |
add 16dp padding to title and subtitle | disabled |