Thanks to visit codestin.com
Credit goes to github.com

Skip to content

darothub/DarotToastLib

Repository files navigation

DarotToastLib

API

The library is a flexible implementation of toast message display in android application development. It allows almost full customization of displaying a toast message including changing the background drawable, text color to mention few.

Screenshot #Add the JitPack repository to your build file(project)

	allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }

Gradle

 implementation 'com.github.darothub:DarotToastLib:version'

Simple usage in an activity

 gdToast("Hello World!", Gravity.CENTER)

Show toast with resource drawable icon

 gdToast("Hello World", R.drawable.ic_android_green_24dp, Gravity.BOTTOM)

Show toast with preferred coordinates Pair(x, y)

 gdToast("Hello World", Gravity.CENTER, Pair(0, 20))

Show toast with resource background color

 gdToast("Hello World",R.drawable.ic_android_green_24dp, R.color.newColor, Gravity.BOTTOM)

Show toast with any drawable derived icon

 gdToast("Hello World", getDrawable(R.drawable.ic_android_green_24dp))

Show toast with string background color

 gdToast(
       message = "Hello World",
       icon = R.drawable.ic_android_green_24dp,
       backgroundColor = "#000000",
       textColor = R.color.newColor,
       gravity = Gravity.CENTER,
       toastDuration = Toast.LENGTH_LONG
   )

Show toast with preferred position

gdToast(
       message = "Hello World",
       icon = R.drawable.ic_android_green_24dp,
       backgroundColor = R.color.newColor,
       textColor = R.color.colorPrimaryDark,
       gravity = Gravity.TOP,
       textGravity = Gravity.START,
       x_Offset = 10,
       y_OffSet = 20,
       toastDuration = Toast.LENGTH_SHORT
   )

To apply a custom drawable background

Darot.getGdDrawableBackgrnd = your-new-drawable-xml

Show simple error toast

 gdErrorToast("Error World", Gravity.TOP)

Simple usage in a fragment

 requireActivity.gdToast("Hello World!", Gravity.CENTER)

License

  Copyright 2020 Durosomo Abdulrasaq Darot

  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.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages