The inflating a custom toast it is not positioned on the top like the system toast using Toast.makeToast(). Is it possible to position the custom inflated toast to the same place as the system toast?
system toast using Toast.makeText()
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toastLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#00000000"
tools:ignore="UseCompoundDrawables">
<androidx.cardview.widget.CardView
android:id="@+id/containerView"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:cardCornerRadius="40dp"
app:cardElevation="16dp"
android:background="@android:color/darker_gray"
app:cardUseCompatPadding="true"
tools:ignore="UnusedAttribute">
<TextView
android:id="@+id/toastTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</androidx.cardview.widget.CardView>
</LinearLayout>
I think the problem is using cardElevation the higher the value the lower it appear on the scree. Any idea to overcome this problem?