material-tip

介绍:

一个material提示框。

运行效果:

使用说明:

Step 1. 在root build.gradle中添加:  

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

Step 2. 添加 dependency

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

自定义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 方法

withButtonListener(ButtonListener)

设置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)

设置提示的 title

withText(String)

设置提示的 text

withPositive(String)

设置提示的确定按钮文字

withNegative(String)

设置提示的取消按钮文字

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();
已下载
0