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.
This library follows AndroidX's revisions.
repositories {
google()
jcenter()
}
dependencies {
implementation "com.google.android.material:material:$version"
implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:$version"
}
For older support library, use legacy artifacts.
implementation "com.android.support:design:$version"
implementation "com.hendraanggrian:collapsingtoolbarlayout-subtitle:$version"
Treat SubtitleCollapsingToolbarLayout
just like a regular CollapsingToolbarLayout
.
<androidx.coordinatorlayout.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">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.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 -->
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.SubtitleCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<!-- content goes here -->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
SubtitleCollapsingToolbarLayout
has all the attributes of CollapsingToolbarLayout
,
and a few extras.
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 |
Copyright 2017 Hendra Anggrian
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.