HuxyApp is a Library eases creating custom and styled toast notifications with few lines of code.
- Android.
- Java.
Step 1.
- Add the JitPack repository to your build file as below :
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2.
- Add the dependency
dependencies {
implementation 'com.github.huxaiphaer:HuxyLab:1.0.0'
}
Then "walaaa", you are good to go. :)
HuxyApp.successToast(Context, "No internet connection please.");
The code above enables a developer to set the Context , Message , Position of the toast , xOffset and yOffset.
So the developer can be able to set the properties of the application. Since this is the Success Toast , it comes with a GREEN background color.
Below is the sample of the Toast :
HuxyApp.successToast(MainActivity.this, "Good Internet Connection")
.setPadding(3)
.setPositionAndOffSet(Gravity.CENTER,0,0);
Below is the Example of Danger toast, you need to specify the dangerToast()
. By default this toast's background is RED.
HuxyApp.dangerToast(MainActivity.this, "Bad Internet Connection")
.setPadding(3)
.setPositionAndOffSet(Gravity.CENTER,0,0);
This is an example of the toast message.
Below is the example of a warningToast. You just need to specify the method warningToast()
. By default this toast's background is ORANGE
HuxyApp.warningToast(MainActivity.this, "Slow Internet Connection")
.setPadding(3)
.setPositionAndOffSet(Gravity.CENTER,0,0);
This is an example of a warning message.
If you want to come up with your custom message, such as changing the Background color or the texColor etc. you
have to use the customToast()
.
Below is the implementation :
String Bg = "#000000";
String textColor ="#ffffff";
HuxyApp.customToast(MainActivity.this, "No internet connection please.",Bg,textColor)
.setPositionAndOffSet(Gravity.BOTTOM,0,20);
Below is a sample of the output.
This library gives a capability of setting a toast message with a different font style such as Times New Roman, Calibri, Arial etc.
Steps to set up a custom font styled toast message.
- Step 1.
Initialize HuxyApp and give it an attribute called setFontStyle(Context,FontPath)
.
HuxyApp.customToast(MainActivity.this, "No internet connection please.",Bg,textColor)
.setPositionAndOffSet(Gravity.BOTTOM,0,0)
.setFontStyle(this,R.font.font_name);
- Step 2.
Download the font of your choice , you can use Google Fonts Site
- Step 3.
Then create a folder called font inside the res folder. e.g app/src/main/res/font
- Step 4.
Place any font of your choice , and then run the application. The toast should appear with your font style or type.
Below is the sample of the output.
Feel free to contribute to this Project , by raising Pull Requests (PRs), so that they are reviewed and merged. Contributors could also take the initiative of reviewing other developers PRs.
If you are happy with the library, please donate.
- Lutaaya Huzaifah Idris Personal Profile