Giter VIP home page Giter VIP logo

android-crouton-sample's Introduction

Crouton Sample Code

Displays the use of the Crouton library with three use cases:

  • Basic preset crouton
  • Styled crouton
  • Custom view crouton

Demo:

Screens:

ย 

See this tutorial for more details.

Quick Usage

Show simple text crouton alert based on string resource:

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

Show styled text crouton alert:

// 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:

// 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 version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#c9dfff"
    android:layout_gravity="center"
    android:orientation="vertical"
    android:paddingTop="15dp"  
    android:paddingBottom="15dp" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:src="@drawable/ic_info" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView1"
            android:layout_below="@+id/textView1"
            android:text="With More Information" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/imageView1"
            android:layout_marginLeft="10dp"
            android:text="Custom Crouton"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>

</LinearLayout>

That's it!

android-crouton-sample's People

Contributors

nesquena avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.