@@ -225,14 +225,17 @@ public CollapsingToolbarLayout(
225
225
ThemeEnforcement .obtainStyledAttributes (
226
226
context , attrs , R .styleable .CollapsingToolbarLayout , defStyleAttr , DEF_STYLE_RES );
227
227
228
- collapsingTitleHelper . setExpandedTextGravity (
228
+ int titleExpandedGravity =
229
229
a .getInt (
230
230
R .styleable .CollapsingToolbarLayout_expandedTitleGravity ,
231
- Gravity .START | Gravity .BOTTOM )) ;
232
- collapsingTitleHelper . setCollapsedTextGravity (
231
+ Gravity .START | Gravity .BOTTOM );
232
+ int titleCollapsedGravity =
233
233
a .getInt (
234
234
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 );
236
239
237
240
expandedMarginStart =
238
241
expandedMarginTop =
@@ -322,14 +325,8 @@ public CollapsingToolbarLayout(
322
325
setSubtitle (a .getText (R .styleable .CollapsingToolbarLayout_subtitle ));
323
326
}
324
327
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 );
333
330
collapsingSubtitleHelper .setExpandedTextAppearance (
334
331
androidx .appcompat .R .style .TextAppearance_AppCompat_Headline );
335
332
collapsingSubtitleHelper .setCollapsedTextAppearance (
@@ -1324,46 +1321,26 @@ public void setCollapsedSubtitleTextColor(@NonNull ColorStateList colors) {
1324
1321
}
1325
1322
1326
1323
/**
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.
1329
1327
*
1330
1328
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedTitleGravity
1331
1329
*/
1332
1330
public void setCollapsedTitleGravity (int gravity ) {
1333
1331
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 ) {
1345
1332
collapsingSubtitleHelper .setCollapsedTextGravity (gravity );
1346
1333
}
1347
1334
1348
1335
/**
1349
- * Returns the horizontal and vertical alignment for title when collapsed.
1336
+ * Returns the horizontal and vertical alignment for titles when collapsed.
1350
1337
*
1351
1338
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_collapsedTitleGravity
1352
1339
*/
1353
1340
public int getCollapsedTitleGravity () {
1354
1341
return collapsingTitleHelper .getCollapsedTextGravity ();
1355
1342
}
1356
1343
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
-
1367
1344
/**
1368
1345
* Sets the text color and size for the expanded title from the specified TextAppearance resource.
1369
1346
*
@@ -1422,46 +1399,25 @@ public void setExpandedSubtitleTextColor(@NonNull ColorStateList colors) {
1422
1399
}
1423
1400
1424
1401
/**
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
1426
1403
* when there is extra space in the expanded bounds beyond what is required for the title itself.
1427
1404
*
1428
1405
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleGravity
1429
1406
*/
1430
1407
public void setExpandedTitleGravity (int gravity ) {
1431
1408
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 ) {
1443
1409
collapsingSubtitleHelper .setExpandedTextGravity (gravity );
1444
1410
}
1445
1411
1446
1412
/**
1447
- * Returns the horizontal and vertical alignment for title when expanded.
1413
+ * Returns the horizontal and vertical alignment for titles when expanded.
1448
1414
*
1449
1415
* @attr ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleGravity
1450
1416
*/
1451
1417
public int getExpandedTitleGravity () {
1452
1418
return collapsingTitleHelper .getExpandedTextGravity ();
1453
1419
}
1454
1420
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
-
1465
1421
/**
1466
1422
* Sets the text size of the expanded title.
1467
1423
*
0 commit comments