Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search View uses app icon instead of logo

Android documents explain that app logo is used everywhere when it is defined. But when the search view expands, app icon is used instead of app logo and I can't find a way to show app logo when search view is in expanded state.

Here are the relevant parts.

Manifest file

<application     android:name="MyApp"     android:allowBackup="true"     android:icon="@drawable/app_icon"     android:label="@string/app_name"     android:logo="@drawable/app_logo"     android:theme="@style/Theme.MyTheme" > 

searchable.xml (setting icon doesn't change anything)

<searchable xmlns:android="http://schemas.android.com/apk/res/android"     android:icon="@drawable/app_logo"     android:label="@string/app_name"     android:hint="@string/search_hint" > </searchable> 

menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >      <item         android:id="@+id/menu_search"         android:actionViewClass="com.actionbarsherlock.widget.SearchView"         android:icon="@drawable/ic_search"         android:showAsAction="always|collapseActionView" /> 

Activity Code

SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = new SearchView(getSupportActionBar().getThemedContext()); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); menu.findItem(R.id.menu_search).setActionView(searchView); 

NOTE: I use ABS SearchView but same thing happens when I switch to default SearchView.

EDIT : I added some screenshots for clarity.

Here I used the star image for app logo, and android image for app icon. The first screenshot is the default view of activity. The second one is the view when I click search button. It shows the android image while I expect it to be the star image.

enter image description here

enter image description here

like image 233
akaya Avatar asked May 14 '13 13:05

akaya


People also ask

What is an app symbol?

What is an app icon? An app icon is a unique image used to represent an app on a user's device. It also appears in Settings and Search and will first be seen by users on the App Store and Google Play store.

How do I use search view?

Android SearchView provides user interface to search query submitted over search provider. SearchView widget can be implemented over ToolBar/ActionBar or inside a layout. SearchView is by default collapsible and set to be iconified using setIconifiedByDefault(true) method of SearchView class.

What is the significance of application icons?

The icon should represent your unique brand image, convey its inherent story, signify the app's purpose, appear outstanding on a user's device screen, and inspire users to download and launch the app.


1 Answers

Set the logo drawable as your icon. Via theme attribute

<item name="android:icon">@drawable/ab_logo</item> 

or in code

getSupportActionBar().setIcon(R.drawable.ab_logo);  
like image 127
Matthias Robbers Avatar answered Sep 28 '22 10:09

Matthias Robbers