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
- Host: GitHub
- URL: https://github.com/codepath/android-crouton-sample
- Owner: codepath
- Created: 2014-03-05T06:02:30.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-06T20:47:44.000Z (about 10 years ago)
- Last Synced: 2023-05-10T14:13:26.595Z (about 2 years ago)
- Language: Java
- Size: 844 KB
- Stars: 29
- Watchers: 11
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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!