diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-02-12 17:39:08 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-02-12 17:39:08 +0000 |
| commit | f5189839251f1ba936187e4b63fb4a5d5fa5aee5 (patch) | |
| tree | 4bb9a94aa4a6994ebb29395c494d821c692e0a2d /core/java/android | |
| parent | b68e35be851ad752f94ade5ef1b8ab101739bc1a (diff) | |
| parent | 11a57f22b4b81c341ba7f5f375f9dfba1bbabacf (diff) | |
Merge "Restrict reflection access to NumberPickers's mSelectionWheelPaint"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/widget/NumberPicker.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 89bb2738b899..dad2669d3de8 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -17,6 +17,8 @@ package android.widget; import android.annotation.CallSuper; +import android.annotation.ColorInt; +import android.annotation.FloatRange; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.Px; @@ -340,7 +342,7 @@ public class NumberPicker extends LinearLayout { /** * The {@link Paint} for drawing the selector. */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private final Paint mSelectorWheelPaint; /** @@ -1718,6 +1720,44 @@ public class NumberPicker extends LinearLayout { } /** + * Sets the text color for all the states (normal, selected, focused) to be the given color. + * + * @param color A color value in the form 0xAARRGGBB. + */ + public void setTextColor(@ColorInt int color) { + mSelectorWheelPaint.setColor(color); + mInputText.setTextColor(color); + invalidate(); + } + + /** + * @return the text color. + */ + @ColorInt + public int getTextColor() { + return mSelectorWheelPaint.getColor(); + } + + /** + * Sets the text size to the given value. This value must be > 0 + * + * @param size The size in pixel units. + */ + public void setTextSize(@FloatRange(from = 0.0, fromInclusive = false) float size) { + mSelectorWheelPaint.setTextSize(size); + mInputText.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); + invalidate(); + } + + /** + * @return the size (in pixels) of the text size in this NumberPicker. + */ + @FloatRange(from = 0.0, fromInclusive = false) + public float getTextSize() { + return mSelectorWheelPaint.getTextSize(); + } + + /** * Makes a measure spec that tries greedily to use the max value. * * @param measureSpec The measure spec. |
