zsolt-szecsi/multiline-collapsingtoolbar


A modified CollapsingToolbarLayout that can deal with multiline titles

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.zsolt-szecsi:multiline-collapsingtoolbar:v1.0.1'
	}
	dependencies {
		implementation("com.github.zsolt-szecsi:multiline-collapsingtoolbar:v1.0.1")
	}
	<dependency>
	    <groupId>com.github.zsolt-szecsi</groupId>
	    <artifactId>multiline-collapsingtoolbar</artifactId>
	    <version>v1.0.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.zsolt-szecsi" % "multiline-collapsingtoolbar" % "v1.0.1"
        
        

                            
    :dependencies [[com.github.zsolt-szecsi/multiline-collapsingtoolbar "v1.0.1"]]
        
        

Readme


multiline-collapsingtoolbar Download

multiline-collapsingtoolbar is a replacement for CollapsingToolbarLayout from the Android Design Support Library which can deal with multiline titles (currently hard-coded to a maximum of 3 lines) in the expanded state. When collapsing the toolbar, the lower lines of the title fade away to leave only the top line visible.

Example

Here you can see the library in use in the Web Opac App:

Demo image

Background Image credit: Tom Murphy VII on Wikimedia Commons, CC-BY-SA 3.0

Installation

If you are using Gradle and the JCenter Maven Repository, installing the library is as simple as adding a new dependency statement.

dependencies {
    compile 'net.opacapp:multiline-collapsingtoolbar:1.0.0'
}

Usage

The library's public API is identical to the version from the support library, so you can use it as a drop-in replacement.

As the Design Support Library, it should be compatible with API 7 (Android 2.1) and above.

XML layout example:

<android.support.design.widget.AppBarLayout
        android:layout_height="192dp"
        android:layout_width="match_parent">
    <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <android.support.v7.widget.Toolbar
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>
    </net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

You can find a simple demo application in the demo module.

Implementation details

Most of the code is copied from the original Support Library classes, the only changes (apart from the package name, imports and automatic code reformatting) are in the CollapsingTextHelper class. The changes there are marked with comments.

The current version 1.0.1 of the library is based on the code from the Design Support Library version 23.2.1.

Contributing

This library is probably not complete and might contain bugs that only occur in constellations we did not yet test. Please do not hesitate to create an issue on GitHub for any problems that cross your way. Please understand that we cannot afford to spend time fixing problems that do not affect our products, but we'll be happy to merge pull requests if you or someone else is able to improve this library.

If you get stuck anywhere in the process, please do not hestitate to ask us anytime at info@opacapp.de.

Please note that we have a Code of Conduct in place that applies to all project-related communication.