Tweak the layout of top app bar

- Update the color of content scrim
- Dynamically change the height of collapsing toolbar according to the
  line count of title
- Fix the jank problem of collapsing toolbar

Fixes: 184615642
Fixes: 185003521
Fixes: 182770567
Fixes: 184209747
Test: visual verified
Change-Id: I78c517eb9bec0b85997085970007481d1a4ef7d3
This commit is contained in:
Mill Chen
2021-04-15 22:11:13 +08:00
parent d0ca25a062
commit feae056067
6 changed files with 33 additions and 12 deletions

View File

@@ -218,10 +218,15 @@ public class SettingsBaseActivity extends FragmentActivity {
v.removeOnLayoutChangeListener(this);
final int count = getLineCount();
if (count > TOOLBAR_MAX_LINE_NUMBER) {
mCollapsingToolbarLayout
.setExpandedTitleTextAppearance(R.style.ToolbarText_MoreThanTwoLines);
} else {
mCollapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ToolbarText);
ViewGroup.LayoutParams lp = mCollapsingToolbarLayout.getLayoutParams();
lp.height = getResources()
.getDimensionPixelSize(R.dimen.toolbar_three_lines_height);
mCollapsingToolbarLayout.setLayoutParams(lp);
} else if (count == TOOLBAR_MAX_LINE_NUMBER) {
ViewGroup.LayoutParams lp = mCollapsingToolbarLayout.getLayoutParams();
lp.height =
getResources().getDimensionPixelSize(R.dimen.toolbar_two_lines_height);
mCollapsingToolbarLayout.setLayoutParams(lp);
}
}
});