|
@@ -84,7 +84,7 @@ public class TitleBar extends Toolbar {
|
84
|
84
|
setSubtitleFont(params);
|
85
|
85
|
colorOverflowButton(params);
|
86
|
86
|
setBackground(params);
|
87
|
|
- centerTitle(params);
|
|
87
|
+ centerTopBarContent(params);
|
88
|
88
|
setTopPadding(params);
|
89
|
89
|
}
|
90
|
90
|
|
|
@@ -102,6 +102,7 @@ public class TitleBar extends Toolbar {
|
102
|
102
|
super.setSubtitle(subtitle);
|
103
|
103
|
setSubtitleFontSize(styleParams);
|
104
|
104
|
setSubtitleFont(styleParams);
|
|
105
|
+ centerSubTitle(styleParams);
|
105
|
106
|
}
|
106
|
107
|
|
107
|
108
|
private void setSubtitleFontSize(StyleParams params) {
|
|
@@ -120,6 +121,11 @@ public class TitleBar extends Toolbar {
|
120
|
121
|
}
|
121
|
122
|
}
|
122
|
123
|
|
|
124
|
+ private void centerTopBarContent(final StyleParams params) {
|
|
125
|
+ centerTitle(params);
|
|
126
|
+ centerSubTitle(params);
|
|
127
|
+ }
|
|
128
|
+
|
123
|
129
|
private void centerTitle(final StyleParams params) {
|
124
|
130
|
final View titleView = getTitleView();
|
125
|
131
|
if (titleView == null) {
|
|
@@ -135,6 +141,21 @@ public class TitleBar extends Toolbar {
|
135
|
141
|
});
|
136
|
142
|
}
|
137
|
143
|
|
|
144
|
+ private void centerSubTitle(final StyleParams params) {
|
|
145
|
+ final TextView subTitleView = getSubtitleView();
|
|
146
|
+ if (subTitleView == null) {
|
|
147
|
+ return;
|
|
148
|
+ }
|
|
149
|
+ ViewUtils.runOnPreDraw(subTitleView, new Runnable() {
|
|
150
|
+ @Override
|
|
151
|
+ public void run() {
|
|
152
|
+ if (params.titleBarSubTitleTextCentered) {
|
|
153
|
+ subTitleView.setX(ViewUtils.getWindowWidth((Activity) getContext()) / 2 - subTitleView.getWidth() / 2);
|
|
154
|
+ }
|
|
155
|
+ }
|
|
156
|
+ });
|
|
157
|
+ }
|
|
158
|
+
|
138
|
159
|
private void setTopPadding(final StyleParams params) {
|
139
|
160
|
setPadding(0, (int) ViewUtils.convertDpToPixel(params.titleBarTopPadding), 0,0);
|
140
|
161
|
}
|