@@ -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 *
0 commit comments