漂亮的Material Design Toasts - Load Toast Library
n342
9年前
Load Toast Library是一个漂亮的Material Design Toasts,拥有反馈动画。
Demo
Usage
Step 1
Gradle
dependencies { compile 'net.steamcrafted:load-toast:1.0.6' }
Step 2
The API is very simple, create a new toast by providing a context:
LoadToast lt = new LoadToast(context);
Change the displayed text:
lt.setText("Sending Reply...");
Then proceed to show the toast:
lt.show();
When your background thingy is done provide feedback to the user and hide the toast:
// Call this if it was successful lt.success(); // Or this method if it failed lt.error();
If you are using translucent actionbar in a full screen activity it will appear over the actionbar, fortunately there is a method to change the y translation:
lt.setTranslationY(100); // y offset in pixels
You can also change the colors of the different toast elements:
lt.setTextColor(Color.RED).setBackgroundColor(Color.GREEN).setProgressColor(Color.BLUE);
These can be chained as you can see.
https://github.com/code-mc/loadtoast