Skip to content

Commit 68462b7

Browse files
committed
Update
1 parent e3f206e commit 68462b7

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

app/src/main/java/com/omarea/common/ui/BannerNotificationManager.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,20 @@ object BannerNotificationManager {
119119
}
120120
messageView.text = req.message
121121

122-
// Toast luôn tự set kích thước cửa sổ kiểu wrap_content theo nội dung, gán layoutParams
123-
// cho view KHÔNG có tác dụng ép độ rộng (window cha quyết định MeasureSpec, không phải
124-
// layoutParams của view con). Phải dùng minimumWidth để ép độ rộng tối thiểu khi tự đo.
125122
val density = activity.resources.displayMetrics.density
126-
val marginPx = (12 * density).toInt()
127-
val screenWidth = activity.resources.displayMetrics.widthPixels
128-
view.minimumWidth = screenWidth - marginPx * 2
129123

130124
val toast = Toast(activity.applicationContext)
131125
toast.duration = Toast.LENGTH_LONG
132126
@Suppress("DEPRECATION")
133127
toast.view = view
134128

135-
val offsetPx = (24 * density).toInt()
136129
when (req.position) {
137-
BannerPosition.TOP -> toast.setGravity(Gravity.TOP or Gravity.CENTER_HORIZONTAL, 0, offsetPx)
138-
BannerPosition.BOTTOM -> toast.setGravity(Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, offsetPx)
130+
BannerPosition.TOP -> toast.setGravity(
131+
Gravity.TOP or Gravity.CENTER_HORIZONTAL, 0, (80 * density).toInt()
132+
)
133+
BannerPosition.BOTTOM -> toast.setGravity(
134+
Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, (110 * density).toInt()
135+
)
139136
}
140137
toast.show()
141138

0 commit comments

Comments
 (0)