diff options
Diffstat (limited to 'core/java/android/widget/NumberPicker.java')
| -rw-r--r-- | core/java/android/widget/NumberPicker.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index a28cc403ed56..157992a98a4a 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -18,6 +18,8 @@ package android.widget; import android.annotation.CallSuper; import android.annotation.IntDef; +import android.annotation.IntRange; +import android.annotation.Px; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.annotation.Widget; @@ -30,6 +32,7 @@ import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Bundle; import android.text.InputFilter; import android.text.InputType; @@ -88,6 +91,16 @@ import java.util.Locale; * of the current value. Tapping on the current value allows to type in a * desired value. * </li> + * <li> + * If the current theme is derived from {@link android.R.style#Theme_Material} + * the widget presents the current value as a scrolling vertical selector with + * the selected value in the center and the previous and following numbers above + * and below, separated by a divider. The value is changed by flinging vertically. + * The thickness of the divider can be changed by using the + * {@link android.R.attr#selectionDividerHeight} attribute and the color of the + * divider can be changed by using the + * {@link android.R.attr#colorControlNormal} attribute. + * </li> * </ul> * <p> * For an example of using this widget, see {@link android.widget.TimePicker}. @@ -436,14 +449,14 @@ public class NumberPicker extends LinearLayout { /** * Divider for showing item to be selected while scrolling */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private final Drawable mSelectionDivider; /** * The height of the selection divider. */ - @UnsupportedAppUsage - private final int mSelectionDividerHeight; + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) + private int mSelectionDividerHeight; /** * The current scroll state of the number picker. @@ -1556,6 +1569,24 @@ public class NumberPicker extends LinearLayout { return mSelectorIndexToStringCache.get(getValue()); } + /** + * Set the height for the divider that separates the currently selected value from the others. + * @param height The height to be set + */ + public void setSelectionDividerHeight(@IntRange(from = 0) @Px int height) { + mSelectionDividerHeight = height; + invalidate(); + } + + /** + * Retrieve the height for the divider that separates the currently selected value from the + * others. + * @return The height of the divider + */ + public int getSelectionDividerHeight() { + return mSelectionDividerHeight; + } + @Override protected float getTopFadingEdgeStrength() { return TOP_AND_BOTTOM_FADING_EDGE_STRENGTH; |
