diff --git a/platform/android/java/lib/res/layout/snackbar.xml b/platform/android/java/lib/res/layout/snackbar.xml
new file mode 100644
index 00000000000..dbe50eded9a
--- /dev/null
+++ b/platform/android/java/lib/res/layout/snackbar.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
diff --git a/platform/android/java/lib/res/values/dimens.xml b/platform/android/java/lib/res/values/dimens.xml
index cc0f0788aff..a64ac0ac44a 100644
--- a/platform/android/java/lib/res/values/dimens.xml
+++ b/platform/android/java/lib/res/values/dimens.xml
@@ -5,4 +5,5 @@
10dp
16dp
8dp
+ 10dp
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/DialogUtils.kt b/platform/android/java/lib/src/org/godotengine/godot/utils/DialogUtils.kt
index 67538bacd4d..8a3396ca474 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/DialogUtils.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/DialogUtils.kt
@@ -33,11 +33,21 @@ package org.godotengine.godot.utils
import android.app.Activity
import android.app.AlertDialog
import android.content.DialogInterface
+import android.os.Handler
+import android.os.Looper
+import android.view.Gravity
+import android.view.LayoutInflater
+import android.view.MotionEvent
+import android.view.View
+import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import android.widget.LinearLayout
+import android.widget.PopupWindow
+import android.widget.TextView
import org.godotengine.godot.R
+import kotlin.math.abs
/**
* Utility class for managing dialogs.
@@ -183,5 +193,91 @@ internal class DialogUtils {
dialog.show()
}
}
+
+ /**
+ * Displays a Snackbar with an optional action button.
+ *
+ * @param context The Context in which the Snackbar should be displayed.
+ * @param message The message to display in the Snackbar.
+ * @param duration The duration for which the Snackbar should be visible (in milliseconds).
+ * @param actionText (Optional) The text for the action button. If `null`, the button is hidden.
+ * @param actionCallback (Optional) A callback function to execute when the action button is clicked. If `null`, no action is performed.
+ */
+ fun showSnackbar(activity: Activity, message: String, duration: Long = 3000, actionText: String? = null, action: (() -> Unit)? = null) {
+ activity.runOnUiThread {
+ val bottomMargin = activity.resources.getDimensionPixelSize(R.dimen.snackbar_bottom_margin)
+ val inflater = LayoutInflater.from(activity)
+ val customView = inflater.inflate(R.layout.snackbar, null)
+
+ val popupWindow = PopupWindow(
+ customView,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ )
+
+ val messageView = customView.findViewById(R.id.snackbar_text)
+ messageView.text = message
+
+ val actionButton = customView.findViewById