|
6 | 6 | import android.graphics.PorterDuffColorFilter;
|
7 | 7 | import android.graphics.drawable.ColorDrawable;
|
8 | 8 | import android.graphics.drawable.Drawable;
|
| 9 | +import android.os.Build; |
9 | 10 | import android.os.Handler;
|
10 | 11 | import android.os.Looper;
|
11 | 12 | import android.support.annotation.ColorInt;
|
12 | 13 | import android.support.annotation.DrawableRes;
|
13 | 14 | import android.support.annotation.LayoutRes;
|
14 | 15 | import android.support.annotation.NonNull;
|
15 | 16 | import android.support.annotation.StringRes;
|
16 |
| -import android.support.v4.view.ViewCompat; |
17 |
| -import android.support.v4.widget.TextViewCompat; |
18 | 17 | import android.view.LayoutInflater;
|
19 | 18 | import android.view.View;
|
20 | 19 | import android.widget.TextView;
|
@@ -244,7 +243,11 @@ public void run() {
|
244 | 243 | final TextView tvMessage = toast.getView().findViewById(android.R.id.message);
|
245 | 244 | int msgColor = tvMessage.getCurrentTextColor();
|
246 | 245 | //it solve the font of toast
|
247 |
| - TextViewCompat.setTextAppearance(tvMessage, android.R.style.TextAppearance); |
| 246 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| 247 | + tvMessage.setTextAppearance(android.R.style.TextAppearance); |
| 248 | + } else { |
| 249 | + tvMessage.setTextAppearance(tvMessage.getContext(), android.R.style.TextAppearance); |
| 250 | + } |
248 | 251 | if (sMsgColor != COLOR_DEFAULT) {
|
249 | 252 | tvMessage.setTextColor(sMsgColor);
|
250 | 253 | } else {
|
@@ -292,7 +295,11 @@ private static void setBg(final Toast toast) {
|
292 | 295 | new PorterDuffColorFilter(sBgColor, PorterDuff.Mode.SRC_IN)
|
293 | 296 | );
|
294 | 297 | } else {
|
295 |
| - ViewCompat.setBackground(toastView, new ColorDrawable(sBgColor)); |
| 298 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
| 299 | + toastView.setBackground(new ColorDrawable(sBgColor)); |
| 300 | + } else { |
| 301 | + toastView.setBackgroundDrawable(new ColorDrawable(sBgColor)); |
| 302 | + } |
296 | 303 | }
|
297 | 304 | }
|
298 | 305 | }
|
|
0 commit comments