3. Agenda
● What is a Crouton?
● Problems with Toast
● What does a Crouton look like?
● Usage
● Getting started
● Sources
4. What is a Crouton
"A crouton is a piece of sautéed or rebaked
bread, often cubed and seasoned, that is used
to add texture and flavor to salads [...] as an
accompaniment to soups, or eaten as a snack
food.
The word crouton is derived from the French
[...] meaning "crust"." [1]
5. Now what has it to do with Android?
A Crouton is made of bread,
like a Toast.
6. Now what has it to do with Android?
Context aware alternative to
Android's Toast
17. What does a Crouton look like?
Any way you want
new Style.Builder()
.setDuration(int) //in milliseconds
.setTextColor(int) //resId
.setBackgroundDrawable(Drawable) //background drawable
.setBackgroundColor(int) //resource id
.setTileEnabled(boolean) //whether the image should be tiled
.setHeight(int) // WRAP_CONTENT or MATCH_PARENT
.setImageResource(int) //resId
.setTextShadowRadius(float) //shadow radius
.setGravity(int) //one of the Gravity constants
.setTextAppearance(int) //resId
.setInAnimation(Animation) //in animation
// more options
.build(); //creates the Style
18. Usage within your code
//Crouton with String
Crouton.
makeText(this, "Hello Crouton", Style.INFO).
show();
//Crouton with text resource
Crouton.
makeText(this, R.string.hello, Style.INFO).
show();
19. Usage within your code
//Cancels all pending Croutons
Crouton.cancelAllCroutons();
//Clear all Croutons for an Activity
Crouton.clearCroutonsForActivity();
20. Getting started
# clones Crouton to your machine
git clone git://github.com/keyboardsurfer/Crouton.git
# will install Crouton to your local maven repository
cd library && mvn install
<!--include this in your pom.xml's dependency section-->
<dependency>
<artifactId>crouton</artifactId>
<version>1.4</version>
<groupId>de.keyboardsurfer.android.widget</groupId>
</dependency>