Snackbar
android.support.design中的控件
Snackbars 简述
1 提供操作时的轻量级反馈,他们在屏幕的底部显示一个简短的信息在移动设备
2 Snackbar出现在屏幕上的其他控件上,同一时间只能显示一个
3 SnackBar会在超时或是用户交互后自动消失
4 加强版的Toast,轻量级的Dialog
两个重要的方法
setAction(CharSequence, android.view.View.OnClickListener).
通过上面方法可以添加一个点击事件响应
Snackbar.Callback via setCallback(Callback).
在SnackBar显示和消失时候,通过上面方法可以进行消失和显示的消息回调
Constants |
int LENGTH_INDEFINITE Show the Snackbar indefinitely. |
int LENGTH_LONGE Show the Snackbar for a long period of time. |
int LENGTH_SHORT Show the Snackbar for a short period of time |
Mothod |
|
|
|
void dismiss() |
Dismiss the Snackbar |
int getDuration() |
Return the duration. |
View getView() |
Returns the Snackbar’s view. |
boolean isShown() |
Return whether this Snackbar is currently being shown. |
boolean isShownOrQueued() |
Returns whether this Snackbar is currently being shown, or is queued to be shown next. |
Static Snackbar make(View view, CharSequence text, int duration) |
Make a Snackbar to display a message |
Snackbar will try and find a parent view to hold Snackbar’s view from the value given to view. |
Static Snackbar make(View view, int resId, int duration) |
Make a Snackbar to display a message. |
Snackbar setAction(int resId, View.OnClickListener listener) |
Set the action to be displayed in this Snackbar. |
Snackbar setAction(CharSequence text, View.OnClickListener listener) |
Set the action to be displayed in this Snackbar. |
Snackbar setActionTextColor(ColorStateList colors) |