Giter VIP home page Giter VIP logo

material-tip's Introduction

material-tip

Android Library for prompt tip ( according to offer education )

Build Status Android Arsenal git-card

Sample

How to include

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
      ...
      maven { url "https://jitpack.io" }
    }
  }

Step 2. Add the dependency

dependencies {
    compile 'com.github.fcannizzaro:material-tip:1.0.5'
}

Custom View + TipBehavior

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    	<android.support.design.widget.FloatingActionButton
       		...
        	app:layout_behavior="com.github.fcannizzaro.materialtip.TipBehavior"/>

    	...

    	<com.github.fcannizzaro.materialtip.MaterialTip
			android:id="@+id/tip"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_gravity="bottom"
			...
			app:tip_background="color"
			app:tip_color="color"
			app:tip_text_color="color"
			app:tip_title_color="color"
			app:tip_icon="drawable"
			app:tip_negative="string"
			app:tip_positive="string"
			app:tip_text="string"
			app:tip_title="string"/>

</android.support.design.widget.CoordinatorLayout>

Builder Methods

withButtonListener(ButtonListener)

Attach the button listener

new ButtonListener() {

	@Override
	public void onPositive(MaterialTip tip) {
		System.out.println("positive");
    }

    @Override
    public void onNegative(MaterialTip tip) {
		System.out.println("negative");
	}

}

withTitle(String)

Set tip title

withText(String)

Set tip text

withPositive(String)

Set tip positive button text

withNegative(String)

Set tip negative button text

withIcon(Drawable)

Set tip icon

withColor(int)

Set tip primary color

withBackground(int)

Set tip background color

withTitleColor(int)

Set tip title color

withTextColor(int)

Set tip text color

Note

Each builder method is also available with Resources arg (ex. withTextRes, withTitleRes).

Void Methods

show()

animate and show the tip

hide()

animate and hide the tip

toggle()

animate and show/hide the tip

Sample

MaterialTip tip = (MaterialTip) findViewById(R.id.tip);

tip
	.withTitle("Ok Google")
	.withText("Something!")
    .withPositive("save")
    .withNegative("discard")
    .withBackground(Color.parseColor("#363636"))
    .withTextColor(Color.parseColor("#f5f5f5"))
    .withTitleColor(Color.WHITE)
    .setButtonListener(new ButtonListener() {

        @Override
        public void onPositive(MaterialTip tip) {
        	System.out.println("positive");
        }

        @Override
        public void onNegative(MaterialTip tip) {
        	System.out.println("negative");
        }

});

tip.show();

License

MIT - Francesco Cannizzaro

material-tip's People

Contributors

fcannizzaro avatar

Watchers

 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.