I want to do an action bar that looks like this:
and I am not able to do this.
I tried to use that collapse thing described here, but it is not exactly what i want.
For example action bar in google maps looks similar to what I want.
Can somebody advise me how to achieve this?
just do your own search view, it is very simple. you then can include this layout in your activity layout file. This is a simple layout which includes a "search icon" followed by EditText, followed by "clear icon". The clear icon is shown after user types some text.
ActionbarSherlock is a great library. The latest(4.2.0) release has the method to make you search view visible when the activity starts SearchView.setIconified(boolean);
So if you want to make your search view always visible you should use the following code:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//Create the search view
SearchView searchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search for countries…");
searchView.setIconified(false);
menu.add("Search")
.setIcon(R.drawable.abs__ic_search)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With