
adding background color to button swiftui. I think this is better that we show text of Toast on the image which we pass to the makeImageToast function. Step 2: Follow step for setup Jetpack Compose with Android Studio.


(ViewGroup)findViewById(R.id.relativeLayout1)) If you want to display the toast message at the different position then you can use setGravity() method. It only fills the amount of space required for the message and the current activity. Toast.makeText(this, 'Hello, this is a android toast message', Toast.LENGTHLONG).show() Changing the Position of Toast message : By default the toast message is displayed at the bottom of an Activity screen aligned vertically. View view = inflater.inflate(R.layout.cust_toast_layout, A toast provides simple feedback about an operation in a small popup. Here i have created a Custom layout file to be inflated into the Toast notification, and then i have used this layout in Toast notification by using setView() method.ĬustomToastDemoActivity.java LayoutInflater inflater = getLayoutInflater()

Yes, you can add imageview or any view into the toast notification by using setView() method, using this method you can customize the Toast as per your requirement.
