Loading core/java/android/widget/SearchView.java +28 −7 Original line number Diff line number Diff line Loading @@ -627,12 +627,33 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); if ((widthMode == MeasureSpec.AT_MOST || widthMode == MeasureSpec.EXACTLY) && mMaxWidth > 0 && width > mMaxWidth) { super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxWidth, widthMode), heightMeasureSpec); switch (widthMode) { case MeasureSpec.AT_MOST: // If there is an upper limit, don't exceed maximum width (explicit or implicit) if (mMaxWidth > 0) { width = Math.min(mMaxWidth, width); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); width = Math.min(getPreferredWidth(), width); } break; case MeasureSpec.EXACTLY: // If an exact width is specified, still don't exceed any specified maximum width if (mMaxWidth > 0) { width = Math.min(mMaxWidth, width); } break; case MeasureSpec.UNSPECIFIED: // Use maximum width, if specified, else preferred width width = mMaxWidth > 0 ? mMaxWidth : getPreferredWidth(); break; } widthMode = MeasureSpec.EXACTLY; super.onMeasure(MeasureSpec.makeMeasureSpec(width, widthMode), heightMeasureSpec); } private int getPreferredWidth() { return getContext().getResources() .getDimensionPixelSize(R.dimen.search_view_preferred_width); } private void updateViewsVisibility(final boolean collapsed) { Loading Loading @@ -695,7 +716,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { // Should we show the close button? It is not shown if there's no focus, // field is not iconified by default and there is no text in it. final boolean showClose = hasText || (mIconifiedByDefault && !mExpandedInActionView); mCloseButton.setVisibility(showClose ? VISIBLE : INVISIBLE); mCloseButton.setVisibility(showClose ? VISIBLE : GONE); mCloseButton.getDrawable().setState(hasText ? ENABLED_STATE_SET : EMPTY_STATE_SET); } Loading Loading @@ -991,7 +1012,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { */ private void updateVoiceButton(boolean empty) { int visibility = GONE; if (mVoiceButtonEnabled && !isIconified() && (empty || !mSubmitButtonEnabled)) { if (mVoiceButtonEnabled && !isIconified() && empty) { visibility = VISIBLE; mSubmitButton.setVisibility(GONE); } Loading core/res/res/layout/search_bar.xml +4 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ <LinearLayout android:id="@id/closeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="48dp" android:orientation="horizontal" android:focusable="true" android:background="?android:attr/selectableItemBackground"> Loading @@ -51,9 +51,10 @@ <ImageView android:id="@+id/search_app_icon" android:layout_height="48dip" android:layout_width="48dip" android:layout_height="32dip" android:layout_width="32dip" android:layout_gravity="center_vertical" android:scaleType="centerInside" /> </LinearLayout> Loading core/res/res/layout/search_view.xml +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ <ImageView android:id="@+id/search_close_btn" android:layout_width="@dimen/dropdownitem_icon_width" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingLeft="8dip" android:paddingRight="8dip" Loading core/res/res/values/dimens.xml +6 −3 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ <!-- Minimum width of the search view text entry area. --> <dimen name="search_view_text_min_width">160dip</dimen> <!-- Preferred width of the search view. --> <dimen name="search_view_preferred_width">320dip</dimen> <!-- Dialog title height --> <dimen name="alert_dialog_title_height">64dip</dimen> <!-- Dialog button bar height --> Loading Loading @@ -155,12 +158,12 @@ <dimen name="default_gap">16dip</dimen> <!-- Text padding for dropdown items --> <dimen name="dropdownitem_text_padding_left">6dip</dimen> <dimen name="dropdownitem_text_padding_left">8dip</dimen> <!-- Text padding for dropdown items --> <dimen name="dropdownitem_text_padding_right">6dip</dimen> <dimen name="dropdownitem_text_padding_right">8dip</dimen> <!-- Width of the icon in a dropdown list --> <dimen name="dropdownitem_icon_width">48dip</dimen> <dimen name="dropdownitem_icon_width">32dip</dimen> </resources> Loading
core/java/android/widget/SearchView.java +28 −7 Original line number Diff line number Diff line Loading @@ -627,12 +627,33 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); if ((widthMode == MeasureSpec.AT_MOST || widthMode == MeasureSpec.EXACTLY) && mMaxWidth > 0 && width > mMaxWidth) { super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxWidth, widthMode), heightMeasureSpec); switch (widthMode) { case MeasureSpec.AT_MOST: // If there is an upper limit, don't exceed maximum width (explicit or implicit) if (mMaxWidth > 0) { width = Math.min(mMaxWidth, width); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); width = Math.min(getPreferredWidth(), width); } break; case MeasureSpec.EXACTLY: // If an exact width is specified, still don't exceed any specified maximum width if (mMaxWidth > 0) { width = Math.min(mMaxWidth, width); } break; case MeasureSpec.UNSPECIFIED: // Use maximum width, if specified, else preferred width width = mMaxWidth > 0 ? mMaxWidth : getPreferredWidth(); break; } widthMode = MeasureSpec.EXACTLY; super.onMeasure(MeasureSpec.makeMeasureSpec(width, widthMode), heightMeasureSpec); } private int getPreferredWidth() { return getContext().getResources() .getDimensionPixelSize(R.dimen.search_view_preferred_width); } private void updateViewsVisibility(final boolean collapsed) { Loading Loading @@ -695,7 +716,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { // Should we show the close button? It is not shown if there's no focus, // field is not iconified by default and there is no text in it. final boolean showClose = hasText || (mIconifiedByDefault && !mExpandedInActionView); mCloseButton.setVisibility(showClose ? VISIBLE : INVISIBLE); mCloseButton.setVisibility(showClose ? VISIBLE : GONE); mCloseButton.getDrawable().setState(hasText ? ENABLED_STATE_SET : EMPTY_STATE_SET); } Loading Loading @@ -991,7 +1012,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { */ private void updateVoiceButton(boolean empty) { int visibility = GONE; if (mVoiceButtonEnabled && !isIconified() && (empty || !mSubmitButtonEnabled)) { if (mVoiceButtonEnabled && !isIconified() && empty) { visibility = VISIBLE; mSubmitButton.setVisibility(GONE); } Loading
core/res/res/layout/search_bar.xml +4 −3 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ <LinearLayout android:id="@id/closeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="48dp" android:orientation="horizontal" android:focusable="true" android:background="?android:attr/selectableItemBackground"> Loading @@ -51,9 +51,10 @@ <ImageView android:id="@+id/search_app_icon" android:layout_height="48dip" android:layout_width="48dip" android:layout_height="32dip" android:layout_width="32dip" android:layout_gravity="center_vertical" android:scaleType="centerInside" /> </LinearLayout> Loading
core/res/res/layout/search_view.xml +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ <ImageView android:id="@+id/search_close_btn" android:layout_width="@dimen/dropdownitem_icon_width" android:layout_width="wrap_content" android:layout_height="match_parent" android:paddingLeft="8dip" android:paddingRight="8dip" Loading
core/res/res/values/dimens.xml +6 −3 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ <!-- Minimum width of the search view text entry area. --> <dimen name="search_view_text_min_width">160dip</dimen> <!-- Preferred width of the search view. --> <dimen name="search_view_preferred_width">320dip</dimen> <!-- Dialog title height --> <dimen name="alert_dialog_title_height">64dip</dimen> <!-- Dialog button bar height --> Loading Loading @@ -155,12 +158,12 @@ <dimen name="default_gap">16dip</dimen> <!-- Text padding for dropdown items --> <dimen name="dropdownitem_text_padding_left">6dip</dimen> <dimen name="dropdownitem_text_padding_left">8dip</dimen> <!-- Text padding for dropdown items --> <dimen name="dropdownitem_text_padding_right">6dip</dimen> <dimen name="dropdownitem_text_padding_right">8dip</dimen> <!-- Width of the icon in a dropdown list --> <dimen name="dropdownitem_icon_width">48dip</dimen> <dimen name="dropdownitem_icon_width">32dip</dimen> </resources>