@UiThreadTest @Test(expected = IllegalArgumentException.class) public void testSetLastBaselineToBottomHeight_negative() { TextViewCompat.setLastBaselineToBottomHeight(mTextView, -1); }
public static void setLastBaselineToBottomHeight( @NonNull final TextView textView, @Px @IntRange(from = 0) int lastBaselineToBottomHeight) { Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight); final Paint.FontMetricsInt fontMetrics = textView.getPaint().getFontMetricsInt(); final int fontMetricsBottom; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || textView.getIncludeFontPadding()) { fontMetricsBottom = fontMetrics.bottom; } else { fontMetricsBottom = fontMetrics.descent; } if (lastBaselineToBottomHeight > Math.abs(fontMetricsBottom)) { final int paddingBottom = lastBaselineToBottomHeight - fontMetricsBottom; textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), paddingBottom); } }
TextViewCompat { public static void setLastBaselineToBottomHeight( @NonNull final TextView textView, @Px @IntRange(from = 0) int lastBaselineToBottomHeight) { Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight); final Paint.FontMetricsInt fontMetrics = textView.getPaint().getFontMetricsInt(); final int fontMetricsBottom; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || textView.getIncludeFontPadding()) { fontMetricsBottom = fontMetrics.bottom; } else { fontMetricsBottom = fontMetrics.descent; } if (lastBaselineToBottomHeight > Math.abs(fontMetricsBottom)) { final int paddingBottom = lastBaselineToBottomHeight - fontMetricsBottom; textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), paddingBottom); } } }
TextViewCompat { public static void setLastBaselineToBottomHeight( @NonNull final TextView textView, @Px @IntRange(from = 0) int lastBaselineToBottomHeight) { Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight); final Paint.FontMetricsInt fontMetrics = textView.getPaint().getFontMetricsInt(); final int fontMetricsBottom; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || textView.getIncludeFontPadding()) { fontMetricsBottom = fontMetrics.bottom; } else { fontMetricsBottom = fontMetrics.descent; } if (lastBaselineToBottomHeight > Math.abs(fontMetricsBottom)) { final int paddingBottom = lastBaselineToBottomHeight - fontMetricsBottom; textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), paddingBottom); } } private  TextViewCompat(); }
TextViewCompat { public static void setLastBaselineToBottomHeight( @NonNull final TextView textView, @Px @IntRange(from = 0) int lastBaselineToBottomHeight) { Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight); final Paint.FontMetricsInt fontMetrics = textView.getPaint().getFontMetricsInt(); final int fontMetricsBottom; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || textView.getIncludeFontPadding()) { fontMetricsBottom = fontMetrics.bottom; } else { fontMetricsBottom = fontMetrics.descent; } if (lastBaselineToBottomHeight > Math.abs(fontMetricsBottom)) { final int paddingBottom = lastBaselineToBottomHeight - fontMetricsBottom; textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), paddingBottom); } } 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 setLastBaselineToBottomHeight( @NonNull final TextView textView, @Px @IntRange(from = 0) int lastBaselineToBottomHeight) { Preconditions.checkArgumentNonnegative(lastBaselineToBottomHeight); final Paint.FontMetricsInt fontMetrics = textView.getPaint().getFontMetricsInt(); final int fontMetricsBottom; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN || textView.getIncludeFontPadding()) { fontMetricsBottom = fontMetrics.bottom; } else { fontMetricsBottom = fontMetrics.descent; } if (lastBaselineToBottomHeight > Math.abs(fontMetricsBottom)) { final int paddingBottom = lastBaselineToBottomHeight - fontMetricsBottom; textView.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), paddingBottom); } } 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; }