@Test public void testStyle() throws Throwable { onView(withId(R.id.text_view)).perform(setTextAppearance(R.style.TextMediumStyle)); final Resources res = mActivityTestRule.getActivity().getResources(); assertTrue("Styled text view: style", mTextView.getTypeface().isItalic() || (mTextView.getPaint().getTextSkewX() < 0)); assertEquals("Styled text view: color", mTextView.getTextColors().getDefaultColor(), res.getColor(R.color.text_color)); assertEquals("Styled text view: size", mTextView.getTextSize(), (float) res.getDimensionPixelSize(R.dimen.text_medium_size), 1.0f); }
public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= 23) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } }
TextViewCompat { public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= 23) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } } }
TextViewCompat { public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= 23) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } } private  TextViewCompat(); }
TextViewCompat { public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= 23) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } } private  TextViewCompat(); static void setCompoundDrawablesRelative(@NonNull TextView textView,
            @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end,
            @Nullable Drawable bottom); static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView,
            @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end,
            @Nullable Drawable bottom); static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView,
            @DrawableRes int start, @DrawableRes int top, @DrawableRes int end,
            @DrawableRes int bottom); static int getMaxLines(@NonNull TextView textView); static int getMinLines(@NonNull TextView textView); static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId); @NonNull static Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeWithDefaults(@NonNull TextView textView,
            int autoSizeTextType); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeUniformWithConfiguration(
            @NonNull TextView textView,
            int autoSizeMinTextSize,
            int autoSizeMaxTextSize,
            int autoSizeStepGranularity,
            int unit); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull TextView textView,
            @NonNull int[] presetSizes, int unit); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeTextType(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeStepGranularity(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeMinTextSize(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeMaxTextSize(@NonNull TextView textView); @NonNull @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int[] getAutoSizeTextAvailableSizes(@NonNull TextView textView); static void setCustomSelectionActionModeCallback(@NonNull final TextView textView,
                @NonNull final ActionMode.Callback callback); static void setFirstBaselineToTopHeight(
            @NonNull final TextView textView,
            @Px @IntRange(from = 0) final int firstBaselineToTopHeight); static void setLastBaselineToBottomHeight(
            @NonNull final TextView textView,
            @Px @IntRange(from = 0) int lastBaselineToBottomHeight); static int getFirstBaselineToTopHeight(@NonNull final TextView textView); static int getLastBaselineToBottomHeight(@NonNull final TextView textView); static void setLineHeight(@NonNull final TextView textView,
                              @Px @IntRange(from = 0) int lineHeight); }
TextViewCompat { public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= 23) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } } private  TextViewCompat(); static void setCompoundDrawablesRelative(@NonNull TextView textView,
            @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end,
            @Nullable Drawable bottom); static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView,
            @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end,
            @Nullable Drawable bottom); static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView,
            @DrawableRes int start, @DrawableRes int top, @DrawableRes int end,
            @DrawableRes int bottom); static int getMaxLines(@NonNull TextView textView); static int getMinLines(@NonNull TextView textView); static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId); @NonNull static Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeWithDefaults(@NonNull TextView textView,
            int autoSizeTextType); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeUniformWithConfiguration(
            @NonNull TextView textView,
            int autoSizeMinTextSize,
            int autoSizeMaxTextSize,
            int autoSizeStepGranularity,
            int unit); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull TextView textView,
            @NonNull int[] presetSizes, int unit); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeTextType(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeStepGranularity(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeMinTextSize(@NonNull TextView textView); @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int getAutoSizeMaxTextSize(@NonNull TextView textView); @NonNull @SuppressWarnings("RedundantCast") // Intentionally invoking interface method. static int[] getAutoSizeTextAvailableSizes(@NonNull TextView textView); static void setCustomSelectionActionModeCallback(@NonNull final TextView textView,
                @NonNull final ActionMode.Callback callback); static void setFirstBaselineToTopHeight(
            @NonNull final TextView textView,
            @Px @IntRange(from = 0) final int firstBaselineToTopHeight); static void setLastBaselineToBottomHeight(
            @NonNull final TextView textView,
            @Px @IntRange(from = 0) int lastBaselineToBottomHeight); static int getFirstBaselineToTopHeight(@NonNull final TextView textView); static int getLastBaselineToBottomHeight(@NonNull final TextView textView); static void setLineHeight(@NonNull final TextView textView,
                              @Px @IntRange(from = 0) int lineHeight); static final int AUTO_SIZE_TEXT_TYPE_NONE; static final int AUTO_SIZE_TEXT_TYPE_UNIFORM; }