mirror of https://github.com/M66B/FairEmail.git
Get bottom navigation bar size for toasts
This commit is contained in:
parent
7e6c18e21e
commit
c2470e781c
|
@ -49,9 +49,18 @@ public class ToastEx extends Toast {
|
|||
tv.setText(text);
|
||||
toast.setView(view);
|
||||
toast.setDuration(duration);
|
||||
|
||||
// <dimen name="design_bottom_navigation_height">56dp</dimen>
|
||||
int dp = Helper.dp2pixels(context, 2 * 56);
|
||||
toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, dp);
|
||||
int resId = context.getResources().getIdentifier(
|
||||
"design_bottom_navigation_height", "dimen", context.getPackageName());
|
||||
int px = Helper.dp2pixels(context, 2 * 56);
|
||||
if (resId > 0)
|
||||
try {
|
||||
px = 2 * context.getResources().getDimensionPixelSize(resId);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, px);
|
||||
return toast;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue