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.