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 @@ -7,7 +7,6 @@ import android.os.Looper
77import android.view.Gravity
88import android.view.LayoutInflater
99import android.view.View
10- import android.view.ViewGroup
1110import android.widget.ImageView
1211import android.widget.TextView
1312import android.widget.Toast
@@ -112,12 +111,13 @@ object BannerNotificationManager {
112111 }
113112 messageView.text = req.message
114113
115- // Toast mặc định wrap_content theo nội dung -> ép chiều rộng gần bằng màn hình
116- // (trừ lề 2 bên) để có dáng banner tràn ngang như mong muốn.
114+ // Toast luôn tự set kích thước cửa sổ kiểu wrap_content theo nội dung, gán layoutParams
115+ // cho view KHÔNG có tác dụng ép độ rộng (window cha quyết định MeasureSpec, không phải
116+ // layoutParams của view con). Phải dùng minimumWidth để ép độ rộng tối thiểu khi tự đo.
117117 val density = activity.resources.displayMetrics.density
118118 val marginPx = (12 * density).toInt()
119119 val screenWidth = activity.resources.displayMetrics.widthPixels
120- view.layoutParams = ViewGroup . LayoutParams ( screenWidth - marginPx * 2 , ViewGroup . LayoutParams . WRAP_CONTENT )
120+ view.minimumWidth = screenWidth - marginPx * 2
121121
122122 val toast = Toast (activity.applicationContext)
123123 toast.duration = Toast .LENGTH_LONG
You can’t perform that action at this time.
0 commit comments