|
@@ -9,6 +9,7 @@ import android.graphics.Typeface;
|
9
|
9
|
import android.support.annotation.Nullable;
|
10
|
10
|
import android.support.v7.widget.ActionMenuView;
|
11
|
11
|
import android.support.v7.widget.Toolbar;
|
|
12
|
+import android.text.TextUtils;
|
12
|
13
|
import android.view.Menu;
|
13
|
14
|
import android.view.View;
|
14
|
15
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
|
@@ -79,6 +80,8 @@ public class TitleBar extends Toolbar {
|
79
|
80
|
setTitleTextFontSize(params);
|
80
|
81
|
setTitleTextFontWeight(params);
|
81
|
82
|
setSubtitleTextColor(params);
|
|
83
|
+ setSubtitleFontSize(params);
|
|
84
|
+ setSubtitleFont(params);
|
82
|
85
|
colorOverflowButton(params);
|
83
|
86
|
setBackground(params);
|
84
|
87
|
centerTitle(params);
|
|
@@ -90,9 +93,32 @@ public class TitleBar extends Toolbar {
|
90
|
93
|
|
91
|
94
|
public void setTitle(String title, StyleParams styleParams) {
|
92
|
95
|
setTitle(title);
|
|
96
|
+ setTitleTextFont(styleParams);
|
93
|
97
|
centerTitle(styleParams);
|
94
|
98
|
}
|
95
|
99
|
|
|
100
|
+ public void setSubtitle(CharSequence subtitle, StyleParams styleParams) {
|
|
101
|
+ super.setSubtitle(subtitle);
|
|
102
|
+ setSubtitleFontSize(styleParams);
|
|
103
|
+ setSubtitleFont(styleParams);
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ private void setSubtitleFontSize(StyleParams params) {
|
|
107
|
+ TextView subtitleView = getSubtitleView();
|
|
108
|
+ if (subtitleView != null && params.titleBarSubtitleFontSize > 0) {
|
|
109
|
+ subtitleView.setTextSize(params.titleBarSubtitleFontSize);
|
|
110
|
+ }
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+ private void setSubtitleFont(StyleParams params) {
|
|
114
|
+ if (params.titleBarSubtitleFontFamily.hasFont()) {
|
|
115
|
+ TextView subtitleView = getSubtitleView();
|
|
116
|
+ if (subtitleView != null) {
|
|
117
|
+ subtitleView.setTypeface(params.titleBarSubtitleFontFamily.get());
|
|
118
|
+ }
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+
|
96
|
122
|
private void centerTitle(final StyleParams params) {
|
97
|
123
|
final View titleView = getTitleView();
|
98
|
124
|
if (titleView == null) {
|
|
@@ -280,6 +306,17 @@ public class TitleBar extends Toolbar {
|
280
|
306
|
});
|
281
|
307
|
}
|
282
|
308
|
|
|
309
|
+ @Nullable
|
|
310
|
+ private TextView getSubtitleView() {
|
|
311
|
+ if (TextUtils.isEmpty(getSubtitle())) return null;
|
|
312
|
+ return ViewUtils.findChildByClass(this, TextView.class, new ViewUtils.Matcher<TextView>() {
|
|
313
|
+ @Override
|
|
314
|
+ public boolean match(TextView child) {
|
|
315
|
+ return child.getText().equals(getSubtitle());
|
|
316
|
+ }
|
|
317
|
+ });
|
|
318
|
+ }
|
|
319
|
+
|
283
|
320
|
public void setButtonColor(StyleParams.Color titleBarButtonColor) {
|
284
|
321
|
if (!titleBarButtonColor.hasColor()) {
|
285
|
322
|
return;
|