Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

01 Toast Message #1

Merged
merged 3 commits into from
May 3, 2020
Merged

01 Toast Message #1

merged 3 commits into from
May 3, 2020

Conversation

AnelCC
Copy link
Owner

@AnelCC AnelCC commented May 3, 2020

01 Toast Message

  • Displays a short, momentary text message
  • Does not receive focus underlying View Stay interactive.
  • Quick, informative messages to acknowledges something
  • Can be displayed fro a short or longer amount of time.
  • Can be positioned on the screen
  • Layout and appearance can be customized.

2. Created a simple toast: Short and Long

Simple Toast

var toastType = "Short"
var toastDuration = Toast.LENGTH_SHORT

val toast = Toast.makeText(this, "This is a toast $toastType", toastDuration)
toast.show()

or

Toast.makeText(context, text, duration).show()

shortToast longToast

3. Created a custom toast: Short and Long

Custom Toast

  val inflater = LayoutInflater.from(this)
        val layout = inflater.inflate(R.layout.custom_toast_layout, findViewById(R.id.customToastLayout))

        val tv = layout.findViewById(R.id.textContent) as TextView
        tv.text = "This is a custom toast $toastType"
        val toast = Toast(applicationContext)
        toast.duration = toastDuration
        toast.setGravity(Gravity.BOTTOM or Gravity.START, 100, 100)
        toast.view = layout
        toast.show()

toastShort toastLong

More info here!

@AnelCC AnelCC merged commit 8a07f5f into master May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant