An open API service indexing awesome lists of open source software.

https://github.com/codepath/android-crouton-sample

Demonstrates how to use the crouton alert library
https://github.com/codepath/android-crouton-sample

Last synced: about 2 months ago
JSON representation

Demonstrates how to use the crouton alert library

Awesome Lists containing this project

README

        

# Crouton Sample Code

Displays the use of the [Crouton](https://github.com/keyboardsurfer/Crouton) library with three use cases:

* Basic preset crouton
* Styled crouton
* Custom view crouton

Demo:

Screens:

 

See [this tutorial](http://www.grokkingandroid.com/useful-android-libraries-crouton/) for more details.

## Quick Usage

Show simple text crouton alert based on string resource:

```java
Crouton.showText(this, R.string.simple_text_message, Style.INFO);
```

Show styled text crouton alert:

```java
// Define configuration options
Configuration croutonConfiguration = new Configuration.Builder()
.setDuration(2500).build();
// Define custom styles for crouton
Style style = new Style.Builder()
.setBackgroundColorValue(Color.parseColor("#daffc0"))
.setGravity(Gravity.CENTER_HORIZONTAL)
.setConfiguration(croutonConfiguration)
.setHeight(150)
.setTextColorValue(Color.parseColor("#323a2c")).build();
// Display notice with custom style and configuration
Crouton.showText(this, R.string.styled_text_message, style);
```

Show custom crouton alert:

```java
// Inflate any custom view
View customView = getLayoutInflater().inflate(R.layout.custom_crouton_layout, null);
// Display the view just by calling "show"
Crouton.show(this, customView);
```

and `res/layout/custom_crouton_layout.xml` with the content for the notice:

```xml

```

That's it!