Ensure the height of the toolbar is set

This commit is contained in:
M66B 2024-05-29 11:40:54 +02:00
parent 96686111b8
commit 19adb34026
2 changed files with 6 additions and 1 deletions

View File

@ -117,6 +117,10 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
Toolbar toolbar = holder.findViewById(R.id.toolbar); Toolbar toolbar = holder.findViewById(R.id.toolbar);
View placeholder = holder.findViewById(R.id.placeholder); View placeholder = holder.findViewById(R.id.placeholder);
ViewGroup.LayoutParams lp = toolbar.getLayoutParams();
lp.height = Helper.getActionBarHeight(this);
toolbar.setLayoutParams(lp);
toolbar.setPopupTheme(getThemeId()); toolbar.setPopupTheme(getThemeId());
if (hide_toolbar) { if (hide_toolbar) {
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();

View File

@ -920,7 +920,8 @@ public class Helper {
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
DisplayMetrics dm = context.getResources().getDisplayMetrics(); DisplayMetrics dm = context.getResources().getDisplayMetrics();
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, dm); actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, dm);
} else }
if (actionBarHeight == null || actionBarHeight <= 0)
actionBarHeight = Helper.dp2pixels(context, 56); actionBarHeight = Helper.dp2pixels(context, 56);
} }