Coder Social home page Coder Social logo

phoenix-626 / collapsingtoolbarlayout-subtitle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hendraanggrian/collapsingtoolbarlayout-subtitle

0.0 0.0 0.0 18.51 MB

Standard CollapsingToolbarLayout with subtitle support

License: Apache License 2.0

Kotlin 21.21% Java 78.79%

collapsingtoolbarlayout-subtitle's Introduction

download build license

SubtitleCollapsingToolbarLayout

example_light example_dark

Standard CollapsingToolbarLayout with subtitle support.

  • Just like the title, subtitle text will have to be 1 line.
  • When collapsed, a subtitle would still appear as Toolbar's.
  • Separate configuration for title and subtitle: text color, gravity, etc.

Caveats

Since it uses a lot of CollapsingToolbarLayout resources and API, there are a few:

  • 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 multiline text 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 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"

Usage

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>

Attributes

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

collapsingtoolbarlayout-subtitle's People

Contributors

hendraanggrian avatar timusus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.