Skip to content

Commit 7e6dfce

Browse files
ymarianleticiarossi
authored andcommitted
Bring back CollpasingToolbarLayout MaterialThemeOverlay support
PiperOrigin-RevId: 295971324
1 parent 1abfca9 commit 7e6dfce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/java/com/google/android/material/appbar/CollapsingToolbarLayout.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.android.material.R;
2020

2121
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
22+
import static com.google.android.material.theme.overlay.MaterialThemeOverlay.wrap;
2223

2324
import android.animation.ValueAnimator;
2425
import android.content.Context;
@@ -111,6 +112,7 @@
111112
*/
112113
public class CollapsingToolbarLayout extends FrameLayout {
113114

115+
private static final int DEF_STYLE_RES = R.style.Widget_Design_CollapsingToolbar;
114116
private static final int DEFAULT_SCRIM_ANIMATION_DURATION = 600;
115117

116118
private boolean refreshToolbar = true;
@@ -152,7 +154,9 @@ public CollapsingToolbarLayout(@NonNull Context context, @Nullable AttributeSet
152154
}
153155

154156
public CollapsingToolbarLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
155-
super(context, attrs, defStyleAttr);
157+
super(wrap(context, attrs, defStyleAttr, DEF_STYLE_RES), attrs, defStyleAttr);
158+
// Ensure we are using the correctly themed context rather than the context that was passed in.
159+
context = getContext();
156160

157161
collapsingTextHelper = new CollapsingTextHelper(this);
158162
collapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);
@@ -163,7 +167,7 @@ public CollapsingToolbarLayout(@NonNull Context context, @Nullable AttributeSet
163167
attrs,
164168
R.styleable.CollapsingToolbarLayout,
165169
defStyleAttr,
166-
R.style.Widget_Design_CollapsingToolbar);
170+
DEF_STYLE_RES);
167171

168172
collapsingTextHelper.setExpandedTextGravity(
169173
a.getInt(

0 commit comments

Comments
 (0)