Loading api/current.xml +13 −0 Original line number Diff line number Diff line Loading @@ -237543,6 +237543,19 @@ <parameter name="iconified" type="boolean"> </parameter> </method> <method name="setMaxWidth" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="maxpixels" type="int"> </parameter> </method> <method name="setOnCloseListener" return="void" abstract="false" core/java/android/widget/SearchView.java +43 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,15 @@ import java.util.WeakHashMap; * Provides the user interface elements for the user to enter a search query and submit a * request to a search provider. Shows a list of query suggestions or results, if * available and allows the user to pick a suggestion or result to launch into. * * <p> * <b>XML attributes</b> * <p> * See {@link android.R.styleable#SearchView SearchView Attributes}, * {@link android.R.styleable#View View Attributes} * * @attr ref android.R.styleable#SearchView_iconifiedByDefault * @attr ref android.R.styleable#SearchView_maxWidth */ public class SearchView extends LinearLayout { Loading @@ -80,6 +89,7 @@ public class SearchView extends LinearLayout { private CharSequence mQueryHint; private boolean mQueryRefinement; private boolean mClearingFocus; private int mMaxWidth; private SearchableInfo mSearchable; Loading Loading @@ -198,6 +208,10 @@ public class SearchView extends LinearLayout { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); int maxWidth = a.getDimensionPixelSize(R.styleable.SearchView_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } a.recycle(); // Save voice intent for later queries/launching Loading Loading @@ -434,6 +448,30 @@ public class SearchView extends LinearLayout { return mSuggestionsAdapter; } /** * Makes the view at most this many pixels wide * * @attr ref android.R.styleable#SearchView_maxWidth */ public void setMaxWidth(int maxpixels) { mMaxWidth = maxpixels; requestLayout(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 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); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } private void updateViewsVisibility(final boolean collapsed) { mIconified = collapsed; // Visibility of views that are visible when collapsed Loading @@ -447,6 +485,8 @@ public class SearchView extends LinearLayout { mSubmitButton.setVisibility(mSubmitButtonEnabled && hasText ? visExpanded : GONE); mSearchEditFrame.setVisibility(visExpanded); updateVoiceButton(!hasText); requestLayout(); invalidate(); } private void setImeVisibility(boolean visible) { Loading Loading @@ -537,6 +577,7 @@ public class SearchView extends LinearLayout { //closeSuggestionsAdapter(); mQueryTextView.setDropDownAnimationStyle(0); // no animation mQueryTextView.setThreshold(mSearchable.getSuggestThreshold()); // attach the suggestions adapter, if suggestions are available // The existence of a suggestions authority is the proxy for "suggestions available here" Loading Loading @@ -594,6 +635,8 @@ public class SearchView extends LinearLayout { boolean hasText = !TextUtils.isEmpty(text); if (isSubmitButtonEnabled()) { mSubmitButton.setVisibility(hasText ? VISIBLE : GONE); requestLayout(); invalidate(); } updateVoiceButton(!hasText); if (mOnQueryChangeListener != null) { Loading core/res/res/layout/search_view.xml +66 −57 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/search_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" > Loading @@ -40,19 +40,26 @@ <ImageView android:id="@+id/search_button" android:layout_height="36dip" android:layout_width="match_parent" android:layout_marginRight="7dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center_vertical" android:src="@android:drawable/ic_btn_search" /> <!-- Inner layout contains the app icon, button(s) and EditText --> <LinearLayout android:id="@+id/search_edit_frame" android:layout_width="300dp" android:layout_height="match_parent" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" android:orientation="horizontal"> <!-- Inner layout contains the app icon, button(s) and EditText --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" android:orientation="horizontal" android:background="?android:attr/editTextBackground"> Loading @@ -68,8 +75,9 @@ <AutoCompleteTextView android:id="@+id/search_src_text" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_width="0dp" android:layout_weight="1" android:minWidth="100dp" android:layout_gravity="bottom" android:paddingLeft="8dip" android:paddingRight="6dip" Loading @@ -79,7 +87,6 @@ android:background="@null" android:inputType="text|textAutoComplete" android:imeOptions="actionSearch" android:dropDownWidth="300dp" android:dropDownHeight="wrap_content" android:dropDownAnchor="@id/search_edit_frame" android:dropDownVerticalOffset="0dip" Loading @@ -95,27 +102,29 @@ android:layout_gravity="bottom" android:src="@android:drawable/btn_close" /> </LinearLayout> <ImageView android:id="@+id/search_go_btn" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:src="@android:drawable/ic_btn_find_next" /> </LinearLayout> <ImageButton android:id="@+id/search_voice_btn" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="0dip" android:layout_marginTop="-6.5dip" android:layout_marginBottom="-7dip" android:layout_marginRight="-5dip" android:background="@drawable/btn_search_dialog_voice" android:layout_gravity="center_vertical" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:src="@android:drawable/ic_btn_speak_now" android:background="@android:color/transparent" android:visibility="gone" /> </LinearLayout> core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4271,6 +4271,8 @@ <!-- The default state of the SearchView. If true, it will be iconified when not in use and expanded when clicked. --> <attr name="iconifiedByDefault" format="boolean"/> <!-- An optional maximum width of the SearchView. --> <attr name="maxWidth" /> </declare-styleable> <declare-styleable name="ButtonGroup"> Loading Loading
api/current.xml +13 −0 Original line number Diff line number Diff line Loading @@ -237543,6 +237543,19 @@ <parameter name="iconified" type="boolean"> </parameter> </method> <method name="setMaxWidth" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="maxpixels" type="int"> </parameter> </method> <method name="setOnCloseListener" return="void" abstract="false"
core/java/android/widget/SearchView.java +43 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,15 @@ import java.util.WeakHashMap; * Provides the user interface elements for the user to enter a search query and submit a * request to a search provider. Shows a list of query suggestions or results, if * available and allows the user to pick a suggestion or result to launch into. * * <p> * <b>XML attributes</b> * <p> * See {@link android.R.styleable#SearchView SearchView Attributes}, * {@link android.R.styleable#View View Attributes} * * @attr ref android.R.styleable#SearchView_iconifiedByDefault * @attr ref android.R.styleable#SearchView_maxWidth */ public class SearchView extends LinearLayout { Loading @@ -80,6 +89,7 @@ public class SearchView extends LinearLayout { private CharSequence mQueryHint; private boolean mQueryRefinement; private boolean mClearingFocus; private int mMaxWidth; private SearchableInfo mSearchable; Loading Loading @@ -198,6 +208,10 @@ public class SearchView extends LinearLayout { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0); setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true)); int maxWidth = a.getDimensionPixelSize(R.styleable.SearchView_maxWidth, -1); if (maxWidth != -1) { setMaxWidth(maxWidth); } a.recycle(); // Save voice intent for later queries/launching Loading Loading @@ -434,6 +448,30 @@ public class SearchView extends LinearLayout { return mSuggestionsAdapter; } /** * Makes the view at most this many pixels wide * * @attr ref android.R.styleable#SearchView_maxWidth */ public void setMaxWidth(int maxpixels) { mMaxWidth = maxpixels; requestLayout(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 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); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } private void updateViewsVisibility(final boolean collapsed) { mIconified = collapsed; // Visibility of views that are visible when collapsed Loading @@ -447,6 +485,8 @@ public class SearchView extends LinearLayout { mSubmitButton.setVisibility(mSubmitButtonEnabled && hasText ? visExpanded : GONE); mSearchEditFrame.setVisibility(visExpanded); updateVoiceButton(!hasText); requestLayout(); invalidate(); } private void setImeVisibility(boolean visible) { Loading Loading @@ -537,6 +577,7 @@ public class SearchView extends LinearLayout { //closeSuggestionsAdapter(); mQueryTextView.setDropDownAnimationStyle(0); // no animation mQueryTextView.setThreshold(mSearchable.getSuggestThreshold()); // attach the suggestions adapter, if suggestions are available // The existence of a suggestions authority is the proxy for "suggestions available here" Loading Loading @@ -594,6 +635,8 @@ public class SearchView extends LinearLayout { boolean hasText = !TextUtils.isEmpty(text); if (isSubmitButtonEnabled()) { mSubmitButton.setVisibility(hasText ? VISIBLE : GONE); requestLayout(); invalidate(); } updateVoiceButton(!hasText); if (mOnQueryChangeListener != null) { Loading
core/res/res/layout/search_view.xml +66 −57 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/search_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" > Loading @@ -40,19 +40,26 @@ <ImageView android:id="@+id/search_button" android:layout_height="36dip" android:layout_width="match_parent" android:layout_marginRight="7dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center_vertical" android:src="@android:drawable/ic_btn_search" /> <!-- Inner layout contains the app icon, button(s) and EditText --> <LinearLayout android:id="@+id/search_edit_frame" android:layout_width="300dp" android:layout_height="match_parent" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" android:orientation="horizontal"> <!-- Inner layout contains the app icon, button(s) and EditText --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center_vertical" android:orientation="horizontal" android:background="?android:attr/editTextBackground"> Loading @@ -68,8 +75,9 @@ <AutoCompleteTextView android:id="@+id/search_src_text" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_width="0dp" android:layout_weight="1" android:minWidth="100dp" android:layout_gravity="bottom" android:paddingLeft="8dip" android:paddingRight="6dip" Loading @@ -79,7 +87,6 @@ android:background="@null" android:inputType="text|textAutoComplete" android:imeOptions="actionSearch" android:dropDownWidth="300dp" android:dropDownHeight="wrap_content" android:dropDownAnchor="@id/search_edit_frame" android:dropDownVerticalOffset="0dip" Loading @@ -95,27 +102,29 @@ android:layout_gravity="bottom" android:src="@android:drawable/btn_close" /> </LinearLayout> <ImageView android:id="@+id/search_go_btn" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:src="@android:drawable/ic_btn_find_next" /> </LinearLayout> <ImageButton android:id="@+id/search_voice_btn" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="0dip" android:layout_marginTop="-6.5dip" android:layout_marginBottom="-7dip" android:layout_marginRight="-5dip" android:background="@drawable/btn_search_dialog_voice" android:layout_gravity="center_vertical" android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:src="@android:drawable/ic_btn_speak_now" android:background="@android:color/transparent" android:visibility="gone" /> </LinearLayout>
core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4271,6 +4271,8 @@ <!-- The default state of the SearchView. If true, it will be iconified when not in use and expanded when clicked. --> <attr name="iconifiedByDefault" format="boolean"/> <!-- An optional maximum width of the SearchView. --> <attr name="maxWidth" /> </declare-styleable> <declare-styleable name="ButtonGroup"> Loading