项目作者: hendraanggrian

项目描述 :
Standard CollapsingToolbarLayout with subtitle support
高级语言: Java
项目地址: git://github.com/hendraanggrian/collapsingtoolbarlayout-subtitle.git
创建时间: 2017-01-11T16:12:45Z
项目社区:https://github.com/hendraanggrian/collapsingtoolbarlayout-subtitle

开源协议:Apache License 2.0

下载


Travis CI
Codecov
Maven Central
Nexus Snapshot
Android SDK

SubtitleCollapsingToolbarLayout

Material preview.
Material You preview.

A carbon copy of CollapsingToolbarLayout
with subtitle support. During collapsed state, the subtitle would still appear
as Toolbar’s. There should be no learning curve because it works just like
CollapsingToolbarLayout. Supports Material Design 3 styling.

But because this library uses restricted APIs and private resources from Material Components,
there are a few caveats:

  • Only safe to use with the same version of material components.
  • Deceptive package name.

Also…

It is detabable if we even need this library. If the material guidelines says
it’s ok to have a subtitle in toolbar layout, then they surely would’ve already
implemented such feature. If it doesn’t say anything about subtitle (which is
odds because Toolbar has it), then we probably shouldn’t use it out of respect
to the guidelines.

Download

This library’s versioning follows Material Components releases.
Which in turn, follows AndroidX releases.

  1. repositories {
  2. mavenCentral()
  3. google()
  4. }
  5. dependencies {
  6. implementation "com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:$version"
  7. }

Usage

Treat SubtitleCollapsingToolbarLayout just like a regular
CollapsingToolbarLayout.

  1. <androidx.coordinatorlayout.widget.CoordinatorLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent">
  6. <com.google.android.material.appbar.AppBarLayout
  7. android:layout_width="match_parent"
  8. android:layout_height="wrap_content">
  9. <com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. app:contentScrim="?colorPrimary"
  13. app:layout_scrollFlags="scroll|exitUntilCollapsed"
  14. app:subtitle="Papua, Indonesia"
  15. app:title="Raja Ampat">
  16. <!-- collapsing toolbar content goes here -->
  17. <androidx.appcompat.widget.Toolbar
  18. android:layout_width="match_parent"
  19. android:layout_height="?actionBarSize"
  20. app:layout_collapseMode="pin"></androidx.appcompat.widget.Toolbar>
  21. </android.support.design.widget.SubtitleCollapsingToolbarLayout>
  22. </com.google.android.material.appbar.AppBarLayout>
  23. <!-- content goes here -->
  24. </androidx.coordinatorlayout.widget.CoordinatorLayout>

Material Design 3

Material3 medium style.
Material3 large style.

SubtitleCollapsingToolbarLayout will automatically switch to Material Design 3
style by using Theme.Material3.* in your app, no configuration needed.

By default, medium style is applied. To use large style, reference an attribute
subtitleCollapsingToolbarLayoutLargeStyle in your XML.

  1. <com.google.android.material.appbar.SubtitleCollapsingToolbarLayout
  2. style="?attr/subtitleCollapsingToolbarLayoutLargeStyle"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"></com.google.android.material.appbar.SubtitleCollapsingToolbarLayout>