@@ -92,6 +92,19 @@ public AppMsg(Activity context) {
92
92
public static AppMsg makeText (Activity context , CharSequence text , Style style ) {
93
93
return makeText (context , text , style , R .layout .app_msg );
94
94
}
95
+
96
+ /**
97
+ * @author mengguoqiang 扩展支持设置字体大小
98
+ * Make a {@link AppMsg} that just contains a text view.
99
+ *
100
+ * @param context The context to use. Usually your
101
+ * {@link android.app.Activity} object.
102
+ * @param text The text to show. Can be formatted text.
103
+ * @param style The style with a background and a duration.
104
+ */
105
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , float textSize ) {
106
+ return makeText (context , text , style , R .layout .app_msg , textSize );
107
+ }
95
108
96
109
/**
97
110
* Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
@@ -108,6 +121,23 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style,
108
121
109
122
return makeText (context , text , style , v , true );
110
123
}
124
+
125
+ /**
126
+ * @author mengguoqiang 扩展支持字体大小
127
+ * Make a {@link AppMsg} with a custom layout. The layout must have a {@link TextView} com id {@link android.R.id.message}
128
+ *
129
+ * @param context The context to use. Usually your
130
+ * {@link android.app.Activity} object.
131
+ * @param text The text to show. Can be formatted text.
132
+ * @param style The style with a background and a duration.
133
+ */
134
+ public static AppMsg makeText (Activity context , CharSequence text , Style style , int layoutId , float textSize ) {
135
+ LayoutInflater inflate = (LayoutInflater )
136
+ context .getSystemService (Context .LAYOUT_INFLATER_SERVICE );
137
+ View v = inflate .inflate (layoutId , null );
138
+
139
+ return makeText (context , text , style , v , true , textSize );
140
+ }
111
141
112
142
/**
113
143
* Make a non-floating {@link AppMsg} with a custom view presented inside the layout.
@@ -136,11 +166,29 @@ public static AppMsg makeText(Activity context, CharSequence text, Style style,
136
166
* @param floating true if it'll float.
137
167
*/
138
168
private static AppMsg makeText (Activity context , CharSequence text , Style style , View view , boolean floating ) {
169
+ return makeText (context , text , style , view , floating , 0 );
170
+ }
171
+
172
+ /**
173
+ *
174
+ * @author mengguoqiang 扩展支持设置字体大小
175
+ * Make a {@link AppMsg} with a custom view. It can be used to create non-floating notifications if floating is false.
176
+ *
177
+ * @param context The context to use. Usually your
178
+ * {@link android.app.Activity} object.
179
+ * @param view
180
+ * View to be used.
181
+ * @param text The text to show. Can be formatted text.
182
+ * @param style The style with a background and a duration.
183
+ * @param floating true if it'll float.
184
+ */
185
+ private static AppMsg makeText (Activity context , CharSequence text , Style style , View view , boolean floating , float textSize ) {
139
186
AppMsg result = new AppMsg (context );
140
187
141
188
view .setBackgroundResource (style .background );
142
189
143
190
TextView tv = (TextView ) view .findViewById (android .R .id .message );
191
+ if (textSize > 0 ) tv .setTextSize (textSize );
144
192
tv .setText (text );
145
193
146
194
result .mView = view ;
0 commit comments