summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java1
-rw-r--r--core/java/android/widget/NumberPicker.java44
-rw-r--r--core/res/res/drawable/number_picker_divider_material.xml21
-rw-r--r--core/res/res/layout/number_picker_material.xml25
-rw-r--r--core/res/res/values/styles_material.xml12
5 files changed, 96 insertions, 7 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 33da937c80c9..126540f36629 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -17115,6 +17115,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* Also calls {@link StateListAnimator#jumpToCurrentState()} if there is a StateListAnimator
* attached to this view.
*/
+ @CallSuper
public void jumpDrawablesToCurrentState() {
if (mBackground != null) {
mBackground.jumpToCurrentState();
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index 16dc26db96ca..e7d9226d66bc 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -16,6 +16,7 @@
package android.widget;
+import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.Widget;
import android.content.Context;
@@ -608,7 +609,16 @@ public class NumberPicker extends LinearLayout {
mSolidColor = attributesArray.getColor(R.styleable.NumberPicker_solidColor, 0);
- mSelectionDivider = attributesArray.getDrawable(R.styleable.NumberPicker_selectionDivider);
+ final Drawable selectionDivider = attributesArray.getDrawable(
+ R.styleable.NumberPicker_selectionDivider);
+ if (selectionDivider != null) {
+ selectionDivider.setCallback(this);
+ selectionDivider.setLayoutDirection(getLayoutDirection());
+ if (selectionDivider.isStateful()) {
+ selectionDivider.setState(getDrawableState());
+ }
+ }
+ mSelectionDivider = selectionDivider;
final int defSelectionDividerHeight = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT,
@@ -1499,6 +1509,38 @@ public class NumberPicker extends LinearLayout {
removeAllCallbacks();
}
+ @CallSuper
+ @Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+
+ final int[] state = getDrawableState();
+
+ if (mSelectionDivider != null && mSelectionDivider.isStateful()) {
+ mSelectionDivider.setState(state);
+ }
+ }
+
+ @CallSuper
+ @Override
+ public void jumpDrawablesToCurrentState() {
+ super.jumpDrawablesToCurrentState();
+
+ if (mSelectionDivider != null) {
+ mSelectionDivider.jumpToCurrentState();
+ }
+ }
+
+ /** @hide */
+ @Override
+ public void onResolveDrawables(@ResolvedLayoutDir int layoutDirection) {
+ super.onResolveDrawables(layoutDirection);
+
+ if (mSelectionDivider != null) {
+ mSelectionDivider.setLayoutDirection(layoutDirection);
+ }
+ }
+
@Override
protected void onDraw(Canvas canvas) {
if (!mHasSelectorWheel) {
diff --git a/core/res/res/drawable/number_picker_divider_material.xml b/core/res/res/drawable/number_picker_divider_material.xml
new file mode 100644
index 000000000000..2474be0e2460
--- /dev/null
+++ b/core/res/res/drawable/number_picker_divider_material.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:tint="?attr/colorControlNormal"
+ android:shape="rectangle">
+ <solid android:color="@color/black" />
+</shape>
diff --git a/core/res/res/layout/number_picker_material.xml b/core/res/res/layout/number_picker_material.xml
new file mode 100644
index 000000000000..47edec475aa7
--- /dev/null
+++ b/core/res/res/layout/number_picker_material.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<view xmlns:android="http://schemas.android.com/apk/res/android"
+ class="android.widget.NumberPicker$CustomEditText"
+ android:id="@+id/numberpicker_input"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:singleLine="true"
+ android:background="@null"
+ android:textAppearance="@style/TextAppearance.Material.Caption" />
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index f7a42fa707be..7782ed70c0a2 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -630,13 +630,13 @@ please see styles_device_defaults.xml.
</style>
<style name="Widget.Material.NumberPicker" parent="Widget.NumberPicker">
- <item name="internalLayout">@layout/number_picker_with_selector_wheel</item>
+ <item name="internalLayout">@layout/number_picker_material</item>
<item name="solidColor">@color/transparent</item>
- <item name="selectionDivider">@drawable/numberpicker_selection_divider</item>
- <item name="selectionDividerHeight">2dip</item>
- <item name="selectionDividersDistance">48dip</item>
- <item name="internalMinWidth">64dip</item>
- <item name="internalMaxHeight">180dip</item>
+ <item name="selectionDivider">@drawable/number_picker_divider_material</item>
+ <item name="selectionDividerHeight">2dp</item>
+ <item name="selectionDividersDistance">48dp</item>
+ <item name="internalMinWidth">64dp</item>
+ <item name="internalMaxHeight">180dp</item>
<item name="virtualButtonPressedDrawable">?attr/selectableItemBackground</item>
</style>