A snackbar can be shown from top or bottom.
It is customizable and easy to use.You can change the style of the snackbar or apply the predefined styles,which are ERROR,LOADING,COMPLETE,WARNING
STYLE_ERROR
STYLE_COMPLETE CUSTOMIZE YOUR ICON STYLE_LOADINGdependencies{
compile 'com.abby.app:tsnackbar:0.0.1'
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TSnackbar.make(getWindow().getDecorView(),"LOADING PLEASE WAIT...",TSnackbar.LENGTH_LONG)
.setPreDefinedStyle(TSnackbar.STYLE_LOADING)
.show();
TSnackbar.make(getWindow().getDecorView(),"ERROR OCCURED!",TSnackbar.LENGTH_LONG)
.setPreDefinedStyle(TSnackbar.STYLE_ERROR)
.show();
TSnackbar.make(getWindow().getDecorView(),"COMPLETE",TSnackbar.LENGTH_LONG)
.setPreDefinedStyle(TSnackbar.STYLE_COMPLETE)
.show();
TSnackbar.make(getWindow().getDecorView(),"LOADING...",TSnackbar.LENGTH_LONG)
.setIconRes(R.drawable.ic_wifi_black_24dp)
.setBackgroundColor(Color.GREEN)
.show();
}
name | description |
---|---|
setShowsDirection | set the direction the snackbar shows,which can be SHOW_FROM_TOP_TO_BOTTOM or SHOW or SHOW_FROM_BOTTOM_TO_TOP |
setBackgroundColor | set the color of the background |
setAlpha | set the alpha of the background,should be 0 to 255 |
setMessageTextColor | set the color of the message |
setIconRes | set the Icon resource |
setPreDefinedStyle | apply the predefined style,which are STYLE_ERROE,STYLE_COMPLETE,STYLE_LOADING,STYLE_WARNING |
setFadeOrTranslateStyle | set the style the snackbar animate out,which can be STYLE_FADE_OUT or STYLE_TRANSLATE |
Copyright 2017 Abby
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.