FancyToast Android
v2.0.2
将其添加到您的根build.gradle
文件(而不是您的模块build.gradle
文件)中:
allprojects {
repositories {
.. .
mavenCentral()
}
}
该库可在 MavenCentral 上找到
将其添加到模块的build.gradle
文件中(确保版本与上面的 Maven-Central 徽章匹配):
dependencies {
.. .
implementation ' io.github.shashank02051997:FancyToast:2.0.2 '
}
每个方法始终返回一个Toast
对象,因此您可以更多地自定义 Toast。不要忘记show()
方法!
显示默认 Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . DEFAULT , true );
显示成功的Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . SUCCESS , true );
要显示信息 Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . INFO , true );
要显示警告 Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . WARNING , true );
显示错误Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . ERROR , true );
显示混乱的Toast:
FancyToast . makeText ( this , "Hello World !" , FancyToast . LENGTH_LONG , FancyToast . CONFUSING , true );
您还可以通过传递最后一个参数 false 来删除右上角的 Android 图标。
FancyToast . makeText ( yourContext , "I'm a Toast" , duration , type , boolean value ). show ();
您还可以通过传递带或不带 Android 图标(右上角)的图像来创建自定义 Toast:
FancyToast . makeText ( yourContext , "I'm a custom Toast" , duration , type , yourimage , boolean value ). show ();
要显示没有 Android 图标的自定义 Toast:
FancyToast . makeText ( this , "This is Custom Toast with no android icon" , FancyToast . LENGTH_LONG , FancyToast . CONFUSING , R . drawable . ic_android_black_24dp , false );
请点击下面的图片放大。
请分叉此存储库并使用拉取请求做出贡献。
任何贡献,无论大小、主要功能、错误修复,都受到欢迎和赞赏,但都会经过彻底审查。
不要忘记为该存储库加注星标,它会激励我分享更多开源代码
如果这个项目能帮助你减少开发时间,你可以给我一杯咖啡:)
Copyright 2020 Shashank Singhal
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.