
In android, we can customize the layout of our toast notification to change the appearance of based on requirements like include images in toast notification or change the background color of toast notification, etc.įollowing is the pictorial representation of using Custom Toast notification in android applications. Generally, the Toast notification in android will be displayed with simple text like as shown in above image. To know more about creation of Toast in android applications, check this Android Toast with Examples. Generally, the size of Toast will be adjusted based on the space required for the message and it will be displayed on the top of the main content of activity for a short period of time. The Toast will show the message for a small period of time and it will disappear automatically after a timeout. In android, Toast is a small popup notification that is used to display information about the operation which we performed in our app. You can see the example demo video on the youtube URL.So when you run the example again, the toast message will not be shown which means the onCreate method is not invoked when changing screen orientation.This attribute makes the activity not restart when change screen orientation. Please note the activity android:configChanges=”orientation|screenSize” attribute.If you want the activity to not restart during screen orientation change, you can use the below AndroidManifest.xml.Android Change Screen Orientation Without Restart Activity. Toast.makeText(this, msgBuf.toString(), Toast.LENGTH_LONG).show() MsgBuf.append("Current screen orientation is unknown.")

MsgBuf.append("Current screen orientation is portrait ( vertical )") Public class MainActivity extends AppCompatActivity else if(currentScreenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) The core file is MainActivity.java, activity_main.xml, AndroidManifest.xml. You can see the example demo video at the youtube link.Which means each time the screen orientation change, the activity is restarted.

This toast message is displayed when the activity is created in the onCreate method.
