public final class SnackbarUtils
extends java.lang.Object
desc : snackbar工具
author : xuexiang
time : 2018/4/28 下午2:56
| Modifier and Type | Class and Description |
|---|---|
static interface |
SnackbarUtils.Duration |
| Modifier and Type | Field and Description |
|---|---|
static int |
LENGTH_INDEFINITE |
static int |
LENGTH_LONG |
static int |
LENGTH_SHORT |
| Modifier and Type | Method and Description |
|---|---|
static void |
addView(int layoutId,
android.view.ViewGroup.LayoutParams params)
Add view to the snackbar.
|
static void |
addView(android.view.View child,
android.view.ViewGroup.LayoutParams params)
Add view to the snackbar.
|
static void |
dismiss()
Dismiss the snackbar.
|
static android.view.View |
getView()
Return the view of snackbar.
|
SnackbarUtils |
setAction(java.lang.CharSequence text,
int color,
android.view.View.OnClickListener listener)
Set the action.
|
SnackbarUtils |
setAction(java.lang.CharSequence text,
android.view.View.OnClickListener listener)
Set the action.
|
SnackbarUtils |
setBgColor(int color)
Set the color of background.
|
SnackbarUtils |
setBgResource(int bgResource)
Set the resource of background.
|
SnackbarUtils |
setBottomMargin(int bottomMargin)
Set the bottom margin.
|
SnackbarUtils |
setDuration(int duration)
Set the duration.
|
SnackbarUtils |
setMessage(java.lang.CharSequence msg)
Set the message.
|
SnackbarUtils |
setMessageColor(int color)
Set the color of message.
|
void |
show()
Show the snackbar.
|
void |
showError()
Show the snackbar with error style.
|
void |
showSuccess()
Show the snackbar with success style.
|
void |
showWarning()
Show the snackbar with warning style.
|
static SnackbarUtils |
with(android.view.View view)
Set the view to find a parent from.
|
public static final int LENGTH_INDEFINITE
public static final int LENGTH_SHORT
public static final int LENGTH_LONG
public static SnackbarUtils with(android.view.View view)
view - The view to find a parent from.SnackbarUtils instancepublic SnackbarUtils setMessage(java.lang.CharSequence msg)
msg - The message.SnackbarUtils instancepublic SnackbarUtils setMessageColor(int color)
color - The color of message.SnackbarUtils instancepublic SnackbarUtils setBgColor(int color)
color - The color of background.SnackbarUtils instancepublic SnackbarUtils setBgResource(int bgResource)
bgResource - The resource of background.SnackbarUtils instancepublic SnackbarUtils setDuration(int duration)
duration - The duration.
SnackbarUtils instancepublic SnackbarUtils setAction(java.lang.CharSequence text, android.view.View.OnClickListener listener)
text - The text.listener - The click listener.SnackbarUtils instancepublic SnackbarUtils setAction(java.lang.CharSequence text, int color, android.view.View.OnClickListener listener)
text - The text.color - The color of text.listener - The click listener.SnackbarUtils instancepublic SnackbarUtils setBottomMargin(int bottomMargin)
bottomMargin - The size of bottom margin, in pixel.public void show()
public void showSuccess()
public void showWarning()
public void showError()
public static void dismiss()
public static android.view.View getView()
public static void addView(int layoutId,
android.view.ViewGroup.LayoutParams params)
Call it after show()
layoutId - The id of layout.params - The params.public static void addView(android.view.View child,
android.view.ViewGroup.LayoutParams params)
Call it after show()
child - The child view.params - The params.