0

Trying too figure of how too add color too a toast

I tried and I made a regular toast but I'm wanting one with color and effects if possible.

  • A simple google search: https://www.geeksforgeeks.org/how-to-add-a-custom-styled-toast-in-android-using-kotlin/ – javdromero Nov 08 '22 at 15:57
  • That's not working at least for the toast I made? – RileyPQ1462 Nov 08 '22 at 16:13
  • @javdromero The point is that regular toasts can't do that and one has to roll out custom system to (partially) mimic the functionality. Posting a sole link isn't very helpful in clearing out this fundamental assumption. Especially as the "article" is just some code with no explanations at all. It doesn't even explain that it won't show when your app is in the background, like a regular toast will. – Agent_L Nov 08 '22 at 16:14
  • I don't know what you're talking about? – RileyPQ1462 Nov 08 '22 at 16:17
  • @Agent_L then the main error in this case is assuming, and we should let the author explain on detail since it seems he/she has minimal experience on android – javdromero Nov 08 '22 at 17:27
  • Okay I will wait for that. – RileyPQ1462 Nov 08 '22 at 17:33
  • You are the author of this question @RileyPQ1462 , we are the ones waiting – javdromero Nov 08 '22 at 18:24
  • People put color on their I just want know how I can do mine – RileyPQ1462 Nov 08 '22 at 20:11

1 Answers1

0

As mentioned above, the Toast color cannot be customised anymore.

The documentation says: Custom toast views are deprecated. Apps can create a standard text toast with the makeText(Context, CharSequence, int) method, or use a Snackbar when in the foreground. Starting from Android Build.VERSION_CODES.R, apps targeting API level Build.VERSION_CODES.R or higher that are in the background will not have custom toast views displayed.

Depending on your use case, look for other components like Snackbars. For this you can do some customisation: https://m2.material.io/components/snackbars/android

moondev
  • 151
  • 1
  • 4
  • I don't know how make those or what too click on? – RileyPQ1462 Nov 08 '22 at 17:07
  • Also I saw someone post yesterday with a colored? – RileyPQ1462 Nov 08 '22 at 17:42
  • For Snackbar I added the documentation, it's in the link. About being colored, it was indeed possible: https://stackoverflow.com/questions/31175601/how-can-i-change-default-toast-message-color-and-background-color-in-android - but it's now deprecated. Also Toast are intended to be a simple feedback about an operation in a small popup, very limited and less configurations, so my advice would be to either rethink on your design / use another component, instead of doing something trickier. – moondev Nov 09 '22 at 13:05
  • I tried them and it say unsupported on all lines how do I fix? – RileyPQ1462 Nov 09 '22 at 23:59
  • What do I do about it? – RileyPQ1462 Nov 16 '22 at 17:20