Skip to content

Commit 782d260

Browse files
pekingmehunterstich
authored andcommitted
[Collapsing Toolbar] Removed the gravity APIs for subtitle (subtitle shares same gravity as title).
PiperOrigin-RevId: 704844851
1 parent 4bc4381 commit 782d260

File tree

6 files changed

+15
-112
lines changed

6 files changed

+15
-112
lines changed

catalog/java/io/material/catalog/topappbar/res/layout/cat_topappbar_collapsing_filled_action_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
android:layout_height="?attr/collapsingToolbarLayoutMediumWithSubtitleSize"
3535
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
3636
app:expandedTitleGravity="bottom|center_horizontal"
37-
app:expandedSubtitleGravity="bottom|center_horizontal"
3837
app:title="@string/cat_topappbar_collapsing_demo_toolbar_medium_title"
3938
app:subtitle="@string/cat_topappbar_collapsing_demo_toolbar_medium_subtitle"
4039
app:toolbarId="@id/toolbar">

catalog/java/io/material/catalog/topappbar/res/layout/cat_topappbar_collapsing_large_with_subtitle_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
android:layout_height="?attr/collapsingToolbarLayoutLargeWithSubtitleSize"
3535
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
3636
app:expandedTitleGravity="bottom|center_horizontal"
37-
app:expandedSubtitleGravity="bottom|center_horizontal"
3837
app:title="@string/cat_topappbar_collapsing_demo_toolbar_large_title"
3938
app:subtitle="@string/cat_topappbar_collapsing_demo_toolbar_large_subtitle">
4039

catalog/java/io/material/catalog/topappbar/res/layout/cat_topappbar_collapsing_medium_with_subtitle_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
android:layout_height="?attr/collapsingToolbarLayoutMediumWithSubtitleSize"
3535
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
3636
app:expandedTitleGravity="bottom|center_horizontal"
37-
app:expandedSubtitleGravity="bottom|center_horizontal"
3837
app:title="@string/cat_topappbar_collapsing_demo_toolbar_medium_title"
3938
app:subtitle="@string/cat_topappbar_collapsing_demo_toolbar_medium_subtitle">
4039

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

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,17 @@ public CollapsingToolbarLayout(
225225
ThemeEnforcement.obtainStyledAttributes(
226226
context, attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, DEF_STYLE_RES);
227227

228-
collapsingTitleHelper.setExpandedTextGravity(
228+
int titleExpandedGravity =
229229
a.getInt(
230230
R.styleable.CollapsingToolbarLayout_expandedTitleGravity,
231-
Gravity.START | Gravity.BOTTOM));
232-
collapsingTitleHelper.setCollapsedTextGravity(
231+
Gravity.START | Gravity.BOTTOM);
232+
int titleCollapsedGravity =
233233
a.getInt(
234234
R.styleable.CollapsingToolbarLayout_collapsedTitleGravity,
235-
Gravity.START | Gravity.CENTER_VERTICAL));
235+
Gravity.START | Gravity.CENTER_VERTICAL);
236+
237+
collapsingTitleHelper.setExpandedTextGravity(titleExpandedGravity);
238+
collapsingTitleHelper.setCollapsedTextGravity(titleCollapsedGravity);
236239

237240
expandedMarginStart =
238241
expandedMarginTop =
@@ -322,14 +325,8 @@ public CollapsingToolbarLayout(
322325
setSubtitle(a.getText(R.styleable.CollapsingToolbarLayout_subtitle));
323326
}
324327

325-
collapsingSubtitleHelper.setExpandedTextGravity(
326-
a.getInt(
327-
R.styleable.CollapsingToolbarLayout_expandedSubtitleGravity,
328-
Gravity.START | Gravity.BOTTOM));
329-
collapsingSubtitleHelper.setCollapsedTextGravity(
330-
a.getInt(
331-
R.styleable.CollapsingToolbarLayout_collapsedSubtitleGravity,
332-
Gravity.START | Gravity.CENTER_VERTICAL));
328+
collapsingSubtitleHelper.setExpandedTextGravity(titleExpandedGravity);
329+
collapsingSubtitleHelper.setCollapsedTextGravity(titleCollapsedGravity);
333330
collapsingSubtitleHelper.setExpandedTextAppearance(
334331
androidx.appcompat.R.style.TextAppearance_AppCompat_Headline);
335332
collapsingSubtitleHelper.setCollapsedTextAppearance(
@@ -1324,46 +1321,26 @@ public void setCollapsedSubtitleTextColor(@NonNull ColorStateList colors) {
13241321
}
13251322

13261323
/**
1327-
* Sets the horizontal alignment of the collapsed title and the vertical gravity that will be used
1328-
* when there is extra space in the collapsed bounds beyond what is required for the title itself.
1324+
* Sets the horizontal alignment of the collapsed titles and the vertical gravity that will be
1325+
* used when there is extra space in the collapsed bounds beyond what is required for the title
1326+
* itself.
13291327
*
13301328
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedTitleGravity
13311329
*/
13321330
public void setCollapsedTitleGravity(int gravity) {
13331331
collapsingTitleHelper.setCollapsedTextGravity(gravity);
1334-
}
1335-
1336-
/**
1337-
* Sets the horizontal alignment of the collapsed subtitle and the vertical gravity that will be
1338-
* used when there is extra space in the collapsed bounds beyond what is required for the subtitle
1339-
* itself.
1340-
*
1341-
* @attr ref
1342-
* com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedSubtitleGravity
1343-
*/
1344-
public void setCollapsedSubitleGravity(int gravity) {
13451332
collapsingSubtitleHelper.setCollapsedTextGravity(gravity);
13461333
}
13471334

13481335
/**
1349-
* Returns the horizontal and vertical alignment for title when collapsed.
1336+
* Returns the horizontal and vertical alignment for titles when collapsed.
13501337
*
13511338
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedTitleGravity
13521339
*/
13531340
public int getCollapsedTitleGravity() {
13541341
return collapsingTitleHelper.getCollapsedTextGravity();
13551342
}
13561343

1357-
/**
1358-
* Returns the horizontal and vertical alignment for subtitle when collapsed.
1359-
*
1360-
* @attr ref
1361-
* com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedSubtitleGravity
1362-
*/
1363-
public int getCollapsedSubtitleGravity() {
1364-
return collapsingSubtitleHelper.getCollapsedTextGravity();
1365-
}
1366-
13671344
/**
13681345
* Sets the text color and size for the expanded title from the specified TextAppearance resource.
13691346
*
@@ -1422,46 +1399,25 @@ public void setExpandedSubtitleTextColor(@NonNull ColorStateList colors) {
14221399
}
14231400

14241401
/**
1425-
* Sets the horizontal alignment of the expanded title and the vertical gravity that will be used
1402+
* Sets the horizontal alignment of the expanded titles and the vertical gravity that will be used
14261403
* when there is extra space in the expanded bounds beyond what is required for the title itself.
14271404
*
14281405
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleGravity
14291406
*/
14301407
public void setExpandedTitleGravity(int gravity) {
14311408
collapsingTitleHelper.setExpandedTextGravity(gravity);
1432-
}
1433-
1434-
/**
1435-
* Sets the horizontal alignment of the expanded subtitle and the vertical gravity that will be
1436-
* used when there is extra space in the expanded bounds beyond what is required for the subtitle
1437-
* itself.
1438-
*
1439-
* @attr ref
1440-
* com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedSubtitleGravity
1441-
*/
1442-
public void setExpandedSubtitleGravity(int gravity) {
14431409
collapsingSubtitleHelper.setExpandedTextGravity(gravity);
14441410
}
14451411

14461412
/**
1447-
* Returns the horizontal and vertical alignment for title when expanded.
1413+
* Returns the horizontal and vertical alignment for titles when expanded.
14481414
*
14491415
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleGravity
14501416
*/
14511417
public int getExpandedTitleGravity() {
14521418
return collapsingTitleHelper.getExpandedTextGravity();
14531419
}
14541420

1455-
/**
1456-
* Returns the horizontal and vertical alignment for subtitle when expanded.
1457-
*
1458-
* @attr ref
1459-
* com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedSubtitleGravity
1460-
*/
1461-
public int getExpandedSubtitleGravity() {
1462-
return collapsingSubtitleHelper.getExpandedTextGravity();
1463-
}
1464-
14651421
/**
14661422
* Sets the text size of the expanded title.
14671423
*

lib/java/com/google/android/material/appbar/res-public/values/public.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282
<public name="liftOnScrollTargetViewId" type="attr"/>
8383
<public name="collapsedTitleGravity" type="attr"/>
8484
<public name="expandedTitleGravity" type="attr"/>
85-
<public name="collapsedSubtitleGravity" type="attr"/>
86-
<public name="expandedSubtitleGravity" type="attr"/>
8785
<public name="layout_collapseMode" type="attr"/>
8886
<public name="layout_collapseParallaxMultiplier" type="attr"/>
8987
<public name="layout_scrollFlags" type="attr"/>

lib/java/com/google/android/material/appbar/res/values/attrs.xml

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -253,54 +253,6 @@
253253
<flag name="end" value="0x00800005"/>
254254
</attr>
255255

256-
<!-- Specifies how the subtitle should be positioned when collapsed. -->
257-
<attr name="collapsedSubtitleGravity">
258-
<!-- Push subtitle to the top of its container, not changing its size. -->
259-
<flag name="top" value="0x30"/>
260-
<!-- Push subtitle to the bottom of its container, not changing its size. -->
261-
<flag name="bottom" value="0x50"/>
262-
<!-- Push subtitle to the left of its container, not changing its size. -->
263-
<flag name="left" value="0x03"/>
264-
<!-- Push subtitle to the right of its container, not changing its size. -->
265-
<flag name="right" value="0x05"/>
266-
<!-- Place subtitle in the vertical center of its container, not changing its size. -->
267-
<flag name="center_vertical" value="0x10"/>
268-
<!-- Grow the vertical size of the subtitle if needed so it completely fills its container. -->
269-
<flag name="fill_vertical" value="0x70"/>
270-
<!-- Place subtitle in the horizontal center of its container, not changing its size. -->
271-
<flag name="center_horizontal" value="0x01"/>
272-
<!-- Place the subtitle in the center of its container in both the vertical and horizontal axis, not changing its size. -->
273-
<flag name="center" value="0x11"/>
274-
<!-- Push subtitle to the beginning of its container, not changing its size. -->
275-
<flag name="start" value="0x00800003"/>
276-
<!-- Push subtitle to the end of its container, not changing its size. -->
277-
<flag name="end" value="0x00800005"/>
278-
</attr>
279-
280-
<!-- Specifies how the subtitle should be positioned when expanded. -->
281-
<attr name="expandedSubtitleGravity">
282-
<!-- Push subtitle to the top of its container, not changing its size. -->
283-
<flag name="top" value="0x30"/>
284-
<!-- Push subtitle to the bottom of its container, not changing its size. -->
285-
<flag name="bottom" value="0x50"/>
286-
<!-- Push subtitle to the left of its container, not changing its size. -->
287-
<flag name="left" value="0x03"/>
288-
<!-- Push subtitle to the right of its container, not changing its size. -->
289-
<flag name="right" value="0x05"/>
290-
<!-- Place subtitle in the vertical center of its container, not changing its size. -->
291-
<flag name="center_vertical" value="0x10"/>
292-
<!-- Grow the vertical size of the subtitle if needed so it completely fills its container. -->
293-
<flag name="fill_vertical" value="0x70"/>
294-
<!-- Place subtitle in the horizontal center of its container, not changing its size. -->
295-
<flag name="center_horizontal" value="0x01"/>
296-
<!-- Place the subtitle in the center of its container in both the vertical and horizontal axis, not changing its size. -->
297-
<flag name="center" value="0x11"/>
298-
<!-- Push subtitle to the beginning of its container, not changing its size. -->
299-
<flag name="start" value="0x00800003"/>
300-
<!-- Push subtitle to the end of its container, not changing its size. -->
301-
<flag name="end" value="0x00800005"/>
302-
</attr>
303-
304256
<!-- Whether the CollapsingToolbarLayout should draw its own collapsing title. -->
305257
<attr name="titleEnabled" format="boolean"/>
306258
<!-- The title to show when titleEnabled is set to true. -->

0 commit comments

Comments
 (0)