• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

code-mc/loadtoast: Pretty material design toasts with feedback animations

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

code-mc/loadtoast

开源软件地址(OpenSource Url):

https://github.com/code-mc/loadtoast

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

Load Toast Library

The default toasts are ugly and don't really provide much more than a short message. This small library provides a better toast which will give the user feedback by morphing into a checkmark or cross (success and fail). The lifetime of the toast is completely controlled by you.

Demo

Usage

Step 1

Gradle

dependencies {
    compile 'net.steamcrafted:load-toast:1.0.12'
}

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...");

If you don't have a message to display, the toast will shrink to only show the circular loader.

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();

// Or if no feedback is desired you can simply hide the toast
lt.hide();

To properly position the toast use the following method to adjust the Y offset:

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);

In some situations a border might be desired for increased visibility, by default it is transparent:

// Change the border color
lt.setBorderColor(int color);

// Change the border width
lt.setBorderWidthPx(int widthPx);
lt.setBorderWidthDp(int widthDp);
lt.setBorderWidthRes(int resourceId);

When displaying a message in a RTL language you can force the text to marquee from left to right instead of the default right to left:

// pass in false for RTL text, true for LTR text
lt.setTextDirection(boolean isLeftToRight);

These can be chained as you can see.

License

Released under the Apache 2.0 License




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
shem8/MaterialLogin: Login view with material design发布时间:2022-08-17
下一篇:
Mike-bel/MDStudySamples: Material Design Widgets Study Samples发布时间:2022-08-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap