Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set toast style as a theme?

I want to change all toasts in my App by editing themes.xml.

I am using <item name="buttonStyle">@style/MyButton</item> to change my buttons, is there something similar with Toasts, or do I have to create and use MyToast class which extends the built-in Toast?

like image 463
guness Avatar asked Apr 05 '13 11:04

guness


People also ask

How do I change the toast style in android?

Create a new instance of Toast using makeText() method. Use getView() method to get the view of the Toast. Open MainActivity. java file and add function to show toast message.

Where do you put the toast message?

Positioning your Toast A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.


1 Answers

You can change the background of your Toast with this:

<style name="myTheme" parent="@android:styles/Theme.Holo">
  <item name="android:toastFrameBackground">@android:drawable/my_toast</item>
</style>
like image 122
Ahmad Avatar answered Oct 01 '22 01:10

Ahmad