TtSearchView
A reusable SearchView where the appearance of the input field, the search icon and the close icon can be customized by theme attributes.
The client can specify whether TtSearchView will expand when activated by defining ttExpandedWidth. When ttExpandedWidth is set, TtSearchView will not accept any input even while focused and has to be expanded by tapping on it. After TtSearchView is expanded, it behaves as usual.
If ttExpandedWidth is set, and then dynamically changed back to 0.0f, TtSearchView will resize it's with to the one set in the XML file or provided by the set LayoutParams. If that width is too small for the TtSearchView to be usable, you have to manually adjust TtSearchView's width through updateLayoutParams. Note that it is only valid to update this view's width through updateLayoutParams while ttExpandedWidth is 0.0f. When TtSearchView is expandable, the LayoutParams will be updated automatically based on user interaction.
The search icon can be customized and removed via R.styleable.TtSearchView_searchIcon.
When ttIsLocked is set, the TtSearchView is in locked state and cannot be interacted with. The view will then show an explanatory message if expanded - set via ttLockedReason or R.styleable.TtSearchView_ttLockedReason - and an associated icon to replace the default search icon - set via R.styleable.TtSearchView_ttLockedIcon.
All theme attributes used by this control are declared in com.tomtom.tools.android.core.theme
. To use this control, it is mandatory to define these attribute values.
Parameters
The display context.
The attribute set provided in the layout XML file.
The default style attribute set. The default value is R.attr.tt_searchview_style
Constructors
Types
The state of the search view. The view's visual components have a different appearance for each state.
Properties
When set, the TtSearchView is in locked state and cannot be interacted with. The view will then show an explanatory message if expanded, and the search icon will be replaced with a locked state icon.
When ttIsLocked is set, this can be used to provide the reason why the TtSearchView was locked. Note: the reason is also not visible when locked if a search query was entered.
Inherited properties
Functions
Retrieve the current SearchState.
This override is necessary in order to make sure tapping on any part of the SearchView will expand it if it's collapsed. Otherwise, child views would intercept the click and expanding would not work correctly.
When ttIsLocked is set, this can be used to provide the reason why the TtSearchView was locked. Note: reason is also not visible when locked if a search query was entered.
Updates the view appearance according to the given state, such as the visibility of the clear icon, the search indicator etc.