File tree Expand file tree Collapse file tree
app/src/main/java/com/omarea/common/ui Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments