Context sensitive notifications for Android
Crouton is a class that can be used by Android developers that feel the need for an alternative to the Context insensitive Toast.
A Crouton will be displayed at the top of an application window. You can line up multiple Croutons for display, that will be shown one after another.
You can check some features in the Crouton Demo.
- Crouton now can be used on any Android device with API level 4+.
- Changes the package name to
de.keyboardsurfer.android.widget
- Adds possibility to set a custom width
- Can now be added to any ViewGroup (@coreform)
- Integration with TalkBack (@coreform)
- Adds Accessibility features (@coreform)
- Fixes bug that got Crouton out of sync with reality (@coreform)
- New LifecycleCallback (@coreform)
- initializeCroutonView was refactored, to make it easier on the eyes
- removes redundant initialization within Style.Builder
- documentation improvments
Please see the git log
The API is kept as simple as the Toast API:
Create a Crouton for any CharSequence:
Crouton.makeText(Activity, CharSequence, [Style]).show();
Create a Crouton with a String from your application's resources:
Crouton.makeText(Activity, int, Style).show();
Further you can attach a Crouton to any view like this:
Crouton.makeText(Activity, int, Style, int).show();
If you would like a more graphical introduction to Crouton check out this presentation.
##Important!
In your Activity.onDestroy() make sure to call
Crouton.cancelAllCroutons();
to cancel cancel all scheduled Croutons.
This is a workaround and further description is available in #24.
Currently you can use the three different Style attributes displayed below out of the box:
The whole design of a Crouton is defined by Style.
You can use one of the styles Crouton ships with: Style.ALERT, Style.CONFIRM and Style.INFO. Or you can create your own Style.
In general you can modify
- display duration
- dimension settings
- options for the text to display
- custom Views
- appearance & disappearance Animation
- displayed Image
Since Style is the general entry point for tweaking Croutons, go and see for yourself what can be done with it.
The build requires Maven. Operations are very simple:
mvn -f library/pom.xml clean package
will buildjar
library;mvn clean package
will buildjar
library and sample applicationapk
package;mvn -f library/pom.xml clean install
will put Crouton in your local Maven repository.
After putting Crouton in the repository you can add it as a dependency.
<dependency>
<artifactId>crouton</artifactId>
<version>1.6</version>
<groupId>de.keyboardsurfer.android.widget</groupId>
</dependency>
This section is subject to changes.
Feel free to contribute to Crouton.
Either you found a bug or have created a new and awesome feature, just create a pull request.
If you want to start to create a new feature or have any other questions regarding Crouton, file an issue. I'll try to answer as soon as I find the time.
For contributors using Eclipse there's a formatter available at the download section.
In order to reduce merging pains on my end, please use this formatter or format your commit in a way similar to it's example.
If you're using IDEA, the Eclipse Formatter plugin should allow you to use the formatter as well.
The name and the idea of Crouton originates in a blog article by Cyril Mottier.
The Crouton logo has been created by Marie Schweiz.
The initial version was written by Benjamin Weiss at Neofonie Mobile GmbH.