Merge "Update number picker styling for Material" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d3c9df1a34
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
21
core/res/res/drawable/number_picker_divider_material.xml
Normal file
21
core/res/res/drawable/number_picker_divider_material.xml
Normal file
@@ -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>
|
||||
25
core/res/res/layout/number_picker_material.xml
Normal file
25
core/res/res/layout/number_picker_material.xml
Normal file
@@ -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" />
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user