diff --git a/app/src/main/java/com/example/shiftalarm/AlarmUtils.kt b/app/src/main/java/com/example/shiftalarm/AlarmUtils.kt index f4b8fc2..ba75216 100644 --- a/app/src/main/java/com/example/shiftalarm/AlarmUtils.kt +++ b/app/src/main/java/com/example/shiftalarm/AlarmUtils.kt @@ -29,6 +29,27 @@ fun showCustomToast(context: Context, message: String, duration: Int = android.w val toast = android.widget.Toast(context) toast.duration = duration toast.view = layout + toast.setGravity(android.view.Gravity.BOTTOM or android.view.Gravity.CENTER_HORIZONTAL, 0, 150) + toast.show() + } catch (e: Exception) { + // Fallback to default toast if custom toast fails + android.widget.Toast.makeText(context, message, duration).show() + } +} + * 다크모드 지원 커스텀 토스트 표시 + */ +fun showCustomToast(context: Context, message: String, duration: Int = android.widget.Toast.LENGTH_SHORT) { + try { + // Use application context with theme for proper dark mode support + val themedContext = android.view.ContextThemeWrapper(context.applicationContext, R.style.Theme_ShiftAlarm) + val inflater = android.view.LayoutInflater.from(themedContext) + val layout = inflater.inflate(R.layout.custom_toast, null) + val textView = layout.findViewById(R.id.toastText) + textView.text = message + + val toast = android.widget.Toast(context.applicationContext) + toast.duration = duration + toast.view = layout toast.setGravity(android.view.Gravity.BOTTOM or android.view.Gravity.CENTER_HORIZONTAL, 0, 100) toast.show() } catch (e: Exception) { diff --git a/app/src/main/res/drawable/bg_custom_toast.xml b/app/src/main/res/drawable/bg_custom_toast.xml index 740597b..ad25896 100644 --- a/app/src/main/res/drawable/bg_custom_toast.xml +++ b/app/src/main/res/drawable/bg_custom_toast.xml @@ -1,8 +1,9 @@ - - + + + diff --git a/app/src/main/res/layout/custom_toast.xml b/app/src/main/res/layout/custom_toast.xml index 4f83742..4c337bc 100644 --- a/app/src/main/res/layout/custom_toast.xml +++ b/app/src/main/res/layout/custom_toast.xml @@ -4,8 +4,8 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:background="@drawable/bg_custom_toast" - android:paddingHorizontal="16dp" - android:paddingVertical="10dp" + android:paddingHorizontal="20dp" + android:paddingVertical="12dp" android:gravity="center">