Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Override the default AOSP's value of 50ms, which is too short and makes the scrim flicker
on <60Hz displays.
Note that for a better UI, we completely disable the scrim background animation in the
Expressive Design, otherwise we'll see for a moment the scrollable content through the
AppBarLayout. -->
<integer name="collapsingtoolbar_scrim_anim_duration">250</integer>
<integer name="collapsingtoolbar_scrim_anim_duration_expressive">0</integer>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
* the box.
*/
public abstract class CollapsingToolbarBaseActivity extends FragmentActivity {
private static final int SCRIM_ANIMATION_DURATION = 250;

private CollapsingToolbarDelegate mToolbardelegate;
private ToolbarDecorator mToolbarDecorator;
private ViewModel mViewModel;
Expand All @@ -58,9 +56,10 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) {

final ToolbarDecorator toolbarDecorator = getToolbarDecorator();
if (toolbarDecorator.isCollapsingToolbarSupported()) {
// Override the default AOSP's value of 50ms, which is too short and makes the scrim
// flicker on <60Hz displays
getCollapsingToolbarLayout().setScrimAnimationDuration(SCRIM_ANIMATION_DURATION);
final int scrimAnimationDuration = getResources().getInteger(isExpressiveTheme ?
R.integer.collapsingtoolbar_scrim_anim_duration_expressive
: R.integer.collapsingtoolbar_scrim_anim_duration);
getCollapsingToolbarLayout().setScrimAnimationDuration(scrimAnimationDuration);
// Enforce fade in/out and translate collapse effect for the title so that it's
// consistent with the subtitle that doesn't support scaling, which may be selected if
// using non-AOSP sources
Expand All @@ -84,6 +83,9 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) {
// Hide the action button by default when expressive theme is enabled.
setActionButtonEnabled(false);
}
// Our use case requires the CollapsingToolbar to be permanently lifted above the
// scrollable content (safe to disable; less animations, better performance)
getAppBarLayout().setLiftable(false);
} else {
// For better UX (e.g. l10n), apply the marquee effect on the title for non-collapsing
// Toolbar
Expand Down