summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/ActionMenuPresenter.java19
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java24
-rw-r--r--core/java/android/widget/ListPopupWindow.java14
-rw-r--r--core/java/android/widget/Spinner.java11
-rw-r--r--core/res/res/drawable/btn_borderless_material.xml12
-rw-r--r--core/res/res/drawable/btn_default_material.xml10
-rw-r--r--core/res/res/drawable/btn_default_mtrl_shape.xml24
-rw-r--r--core/res/res/drawable/btn_toggle_material.xml13
-rw-r--r--core/res/res/values/attrs.xml17
-rw-r--r--core/res/res/values/dimens_material.xml8
-rw-r--r--core/res/res/values/styles_material.xml9
11 files changed, 94 insertions, 67 deletions
diff --git a/core/java/android/widget/ActionMenuPresenter.java b/core/java/android/widget/ActionMenuPresenter.java
index 7123b9a1e231..ef8c006e1554 100644
--- a/core/java/android/widget/ActionMenuPresenter.java
+++ b/core/java/android/widget/ActionMenuPresenter.java
@@ -19,6 +19,8 @@ package android.widget;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseBooleanArray;
@@ -645,6 +647,23 @@ public class ActionMenuPresenter extends BaseMenuPresenter
super.onInitializeAccessibilityNodeInfo(info);
info.setCanOpenPopup(true);
}
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+
+ // Set up the hotspot bounds to be centered on the image.
+ final Drawable d = getDrawable();
+ final Drawable bg = getBackground();
+ if (d != null && bg != null) {
+ final Rect bounds = d.getBounds();
+ final int height = bottom - top;
+ final int offset = (height - bounds.width()) / 2;
+ final int hotspotLeft = bounds.left - offset;
+ final int hotspotRight = bounds.right + offset;
+ bg.setHotspotBounds(hotspotLeft, 0, hotspotRight, height);
+ }
+ }
}
private class OverflowPopup extends MenuPopupHelper {
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index eb232fd8db5c..6f52db6c94b4 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -130,7 +130,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
}
public AutoCompleteTextView(Context context, AttributeSet attrs) {
- this(context, attrs, com.android.internal.R.attr.autoCompleteTextViewStyle);
+ this(context, attrs, R.attr.autoCompleteTextViewStyle);
}
public AutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -141,23 +141,17 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- mPopup = new ListPopupWindow(context, attrs,
- com.android.internal.R.attr.autoCompleteTextViewStyle);
+ mPopup = new ListPopupWindow(context, attrs, defStyleAttr, defStyleRes);
mPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
- final TypedArray a = context.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);
+ final TypedArray a = context.obtainStyledAttributes(
+ attrs, R.styleable.AutoCompleteTextView, defStyleAttr, defStyleRes);
- mThreshold = a.getInt(
- R.styleable.AutoCompleteTextView_completionThreshold, 2);
+ mThreshold = a.getInt(R.styleable.AutoCompleteTextView_completionThreshold, 2);
mPopup.setListSelector(a.getDrawable(R.styleable.AutoCompleteTextView_dropDownSelector));
- mPopup.setVerticalOffset((int)
- a.getDimension(R.styleable.AutoCompleteTextView_dropDownVerticalOffset, 0.0f));
- mPopup.setHorizontalOffset((int)
- a.getDimension(R.styleable.AutoCompleteTextView_dropDownHorizontalOffset, 0.0f));
-
+
// Get the anchor's id now, but the view won't be ready, so wait to actually get the
// view and store it in mDropDownAnchorView lazily in getDropDownAnchorView later.
// Defaults to NO_ID, in which case the getDropDownAnchorView method will simply return
@@ -167,11 +161,9 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
// For dropdown width, the developer can specify a specific width, or MATCH_PARENT
// (for full screen width) or WRAP_CONTENT (to match the width of the anchored view).
- mPopup.setWidth(a.getLayoutDimension(
- R.styleable.AutoCompleteTextView_dropDownWidth,
+ mPopup.setWidth(a.getLayoutDimension(R.styleable.AutoCompleteTextView_dropDownWidth,
ViewGroup.LayoutParams.WRAP_CONTENT));
- mPopup.setHeight(a.getLayoutDimension(
- R.styleable.AutoCompleteTextView_dropDownHeight,
+ mPopup.setHeight(a.getLayoutDimension(R.styleable.AutoCompleteTextView_dropDownHeight,
ViewGroup.LayoutParams.WRAP_CONTENT));
mHintResource = a.getResourceId(R.styleable.AutoCompleteTextView_completionHintView,
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index 6a514bab9984..3c186e3b9d2b 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -40,6 +41,7 @@ import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.animation.AccelerateDecelerateInterpolator;
+import com.android.internal.R;
import com.android.internal.widget.AutoScrollHelper.AbsListViewAutoScroller;
import java.util.Locale;
@@ -208,6 +210,18 @@ public class ListPopupWindow {
*/
public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
+
+ final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow,
+ defStyleAttr, defStyleRes);
+ mDropDownHorizontalOffset = a.getDimensionPixelOffset(
+ R.styleable.ListPopupWindow_dropDownHorizontalOffset, 0);
+ mDropDownVerticalOffset = a.getDimensionPixelOffset(
+ R.styleable.ListPopupWindow_dropDownVerticalOffset, 0);
+ if (mDropDownVerticalOffset != 0) {
+ mDropDownVerticalOffsetSet = true;
+ }
+ a.recycle();
+
mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes);
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
// Set the default layout direction to match the default locale one
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index 9914800ec6ca..1fc5437c5be8 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -209,17 +209,6 @@ public class Spinner extends AbsSpinner implements OnClickListener {
ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setBackgroundDrawable(a.getDrawable(
com.android.internal.R.styleable.Spinner_popupBackground));
- final int verticalOffset = a.getDimensionPixelOffset(
- com.android.internal.R.styleable.Spinner_dropDownVerticalOffset, 0);
- if (verticalOffset != 0) {
- popup.setVerticalOffset(verticalOffset);
- }
-
- final int horizontalOffset = a.getDimensionPixelOffset(
- com.android.internal.R.styleable.Spinner_dropDownHorizontalOffset, 0);
- if (horizontalOffset != 0) {
- popup.setHorizontalOffset(horizontalOffset);
- }
mPopup = popup;
mForwardingListener = new ForwardingListener(this) {
diff --git a/core/res/res/drawable/btn_borderless_material.xml b/core/res/res/drawable/btn_borderless_material.xml
index 016f0ff15683..08e1060ebad3 100644
--- a/core/res/res/drawable/btn_borderless_material.xml
+++ b/core/res/res/drawable/btn_borderless_material.xml
@@ -14,10 +14,8 @@
limitations under the License.
-->
-<inset xmlns:android="http://schemas.android.com/apk/res/android"
- android:inset="@dimen/control_inset_material">
- <ripple android:color="?attr/colorControlHighlight">
- <item android:id="@id/mask"
- android:drawable="@drawable/btn_default_mtrl_shape" />
- </ripple>
-</inset>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?attr/colorControlHighlight">
+ <item android:id="@id/mask"
+ android:drawable="@drawable/btn_default_mtrl_shape" />
+</ripple>
diff --git a/core/res/res/drawable/btn_default_material.xml b/core/res/res/drawable/btn_default_material.xml
index d00a34839827..ed2b5aacb236 100644
--- a/core/res/res/drawable/btn_default_material.xml
+++ b/core/res/res/drawable/btn_default_material.xml
@@ -14,9 +14,7 @@
limitations under the License.
-->
-<inset xmlns:android="http://schemas.android.com/apk/res/android"
- android:inset="@dimen/control_inset_material">
- <ripple android:color="?attr/colorControlHighlight">
- <item android:drawable="@drawable/btn_default_mtrl_shape" />
- </ripple>
-</inset>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?attr/colorControlHighlight">
+ <item android:drawable="@drawable/btn_default_mtrl_shape" />
+</ripple>
diff --git a/core/res/res/drawable/btn_default_mtrl_shape.xml b/core/res/res/drawable/btn_default_mtrl_shape.xml
index 9235c7686085..6d0f7f8c63c7 100644
--- a/core/res/res/drawable/btn_default_mtrl_shape.xml
+++ b/core/res/res/drawable/btn_default_mtrl_shape.xml
@@ -15,12 +15,18 @@
-->
<!-- Used as the canonical button shape. -->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <corners android:radius="@dimen/control_corner_material" />
- <solid android:color="?attr/colorButtonNormal" />
- <padding android:top="@dimen/control_padding_material"
- android:bottom="@dimen/control_padding_material"
- android:left="@dimen/control_padding_material"
- android:right="@dimen/control_padding_material" />
-</shape>
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:insetLeft="@dimen/button_inset_horizontal_material"
+ android:insetTop="@dimen/button_inset_vertical_material"
+ android:insetRight="@dimen/button_inset_horizontal_material"
+ android:insetBottom="@dimen/button_inset_vertical_material">
+ <shape android:shape="rectangle">
+ <corners android:radius="@dimen/control_corner_material" />
+ <solid android:color="?attr/colorButtonNormal" />
+ <padding android:left="@dimen/button_padding_horizontal_material"
+ android:top="@dimen/button_padding_vertical_material"
+ android:right="@dimen/button_padding_horizontal_material"
+ android:bottom="@dimen/button_padding_vertical_material" />
+ </shape>
+</inset>
diff --git a/core/res/res/drawable/btn_toggle_material.xml b/core/res/res/drawable/btn_toggle_material.xml
index 9726782e0efb..f91d4cc0cde9 100644
--- a/core/res/res/drawable/btn_toggle_material.xml
+++ b/core/res/res/drawable/btn_toggle_material.xml
@@ -15,7 +15,10 @@
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
- android:inset="@dimen/control_inset_material">
+ android:insetLeft="@dimen/button_inset_horizontal_material"
+ android:insetTop="@dimen/button_inset_vertical_material"
+ android:insetRight="@dimen/button_inset_horizontal_material"
+ android:insetBottom="@dimen/button_inset_vertical_material">
<layer-list android:paddingMode="stack">
<item>
<ripple android:color="?attr/colorControlHighlight">
@@ -25,10 +28,10 @@
<corners android:topLeftRadius="@dimen/control_corner_material"
android:topRightRadius="@dimen/control_corner_material"/>
<solid android:color="?attr/colorButtonNormal" />
- <padding android:top="@dimen/control_padding_material"
- android:bottom="@dimen/control_padding_material"
- android:left="@dimen/control_padding_material"
- android:right="@dimen/control_padding_material" />
+ <padding android:left="@dimen/button_padding_horizontal_material"
+ android:top="@dimen/button_padding_vertical_material"
+ android:right="@dimen/button_padding_horizontal_material"
+ android:bottom="@dimen/button_padding_vertical_material" />
</shape>
</item>
</ripple>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index d8b129c4fa44..b5876f08fa98 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -4172,10 +4172,6 @@
<attr name="completionThreshold" format="integer" min="1" />
<!-- Selector in a drop down list. -->
<attr name="dropDownSelector" format="reference|color" />
- <!-- Amount of pixels by which the drop down should be offset vertically. -->
- <attr name="dropDownVerticalOffset" format="dimension" />
- <!-- Amount of pixels by which the drop down should be offset horizontally. -->
- <attr name="dropDownHorizontalOffset" format="dimension" />
<!-- View to anchor the auto-complete dropdown to. If not specified, the text view itself
is used. -->
<attr name="dropDownAnchor" format="reference" />
@@ -4223,6 +4219,13 @@
<!-- Whether the popup window should overlap its anchor view. -->
<attr name="overlapAnchor" format="boolean" />
</declare-styleable>
+ <!-- @hide -->
+ <declare-styleable name="ListPopupWindow">
+ <!-- Amount of pixels by which the drop down should be offset vertically. -->
+ <attr name="dropDownVerticalOffset" format="dimension" />
+ <!-- Amount of pixels by which the drop down should be offset horizontally. -->
+ <attr name="dropDownHorizontalOffset" format="dimension" />
+ </declare-styleable>
<declare-styleable name="ViewAnimator">
<!-- Identifier for the animation to use when a view is shown. -->
<attr name="inAnimation" format="reference" />
@@ -4281,12 +4284,6 @@
<attr name="popupBackground" />
<!-- Window elevation to use for the dropdown in spinnerMode="dropdown". -->
<attr name="popupElevation" />
- <!-- Vertical offset from the spinner widget for positioning the dropdown in
- spinnerMode="dropdown". -->
- <attr name="dropDownVerticalOffset" />
- <!-- Horizontal offset from the spinner widget for positioning the dropdown
- in spinnerMode="dropdown". -->
- <attr name="dropDownHorizontalOffset" />
<!-- Width of the dropdown in spinnerMode="dropdown". -->
<attr name="dropDownWidth" />
<!-- Reference to a layout to use for displaying a prompt in the dropdown for
diff --git a/core/res/res/values/dimens_material.xml b/core/res/res/values/dimens_material.xml
index 972ae5eca014..f5c92995c8d1 100644
--- a/core/res/res/values/dimens_material.xml
+++ b/core/res/res/values/dimens_material.xml
@@ -33,7 +33,6 @@
<dimen name="action_button_min_width_material">48dp</dimen>
<dimen name="action_button_min_height_material">48dp</dimen>
- <dimen name="action_overflow_min_width_material">36dp</dimen>
<dimen name="text_size_display_4_material">112sp</dimen>
<dimen name="text_size_display_3_material">56sp</dimen>
@@ -64,6 +63,13 @@
<dimen name="button_elevation_material">1dp</dimen>
<!-- Z translation to apply when button is pressed -->
<dimen name="button_pressed_z_material">2dp</dimen>
+ <!-- Default insets (outer padding) around buttons -->
+ <dimen name="button_inset_vertical_material">6dp</dimen>
+ <dimen name="button_inset_horizontal_material">@dimen/control_inset_material</dimen>
+ <!-- Default inner padding within buttons -->
+ <dimen name="button_padding_vertical_material">@dimen/control_padding_material</dimen>
+ <dimen name="button_padding_horizontal_material">8dp</dimen>
+
<!-- Default insets (outer padding) around controls -->
<dimen name="control_inset_material">4dp</dimen>
<!-- Default inner padding within controls -->
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index 3ee555254cd1..da32c42cd2dd 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -306,7 +306,7 @@ please see styles_device_defaults.xml.
</style>
<style name="TextAppearance.Material.Widget.TextView.PopupMenu" parent="TextAppearance.Material.Menu" />
- <style name="TextAppearance.Material.Widget.TextView.SpinnerItem" />
+ <style name="TextAppearance.Material.Widget.TextView.SpinnerItem" parent="TextAppearance.Material.Menu" />
<style name="TextAppearance.Material.Widget.DropDownItem" parent="TextAppearance.Material.Menu">
<item name="textColor">?attr/textColorPrimaryDisableOnly</item>
@@ -746,6 +746,7 @@ please see styles_device_defaults.xml.
<item name="popupElevation">@dimen/floating_window_z</item>
<item name="dropDownVerticalOffset">0dip</item>
<item name="dropDownHorizontalOffset">0dip</item>
+ <item name="overlapAnchor">true</item>
<item name="dropDownWidth">wrap_content</item>
<item name="popupPromptView">@layout/simple_dropdown_hint</item>
<item name="gravity">start|center_vertical</item>
@@ -829,6 +830,7 @@ please see styles_device_defaults.xml.
<style name="Widget.Material.PopupMenu.Overflow">
<item name="overlapAnchor">true</item>
+ <item name="dropDownHorizontalOffset">-4dip</item>
</style>
<style name="Widget.Material.ActionButton" parent="Widget.ActionButton">
@@ -837,6 +839,8 @@ please see styles_device_defaults.xml.
<item name="gravity">center</item>
<item name="scaleType">center</item>
<item name="maxLines">2</item>
+ <item name="paddingStart">0dp</item>
+ <item name="paddingEnd">0dp</item>
</style>
<style name="Widget.Material.ActionButton.CloseMode">
@@ -847,8 +851,9 @@ please see styles_device_defaults.xml.
<item name="src">@drawable/ic_menu_moreoverflow_material</item>
<item name="background">?attr/actionBarItemBackground</item>
<item name="contentDescription">@string/action_menu_overflow_description</item>
- <item name="minWidth">@dimen/action_overflow_min_width_material</item>
+ <item name="minWidth">@dimen/action_button_min_width_material</item>
<item name="minHeight">@dimen/action_button_min_height_material</item>
+ <item name="paddingEnd">12dp</item>
<item name="scaleType">center</item>
</style>