Blur the Background of Android Standard Search Dialog
How to blur the background of a standard search dialog?
I didn’t find any good solution on this topic in the web. The common response was “it’s not possible”. So I began to figure out a solution by myself, which finally works fine! Let’s start over:
Because you don’t get a handle of the standard android search dialog it seems to be impossible to blur the background by calling
Window.addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
But there is an other approach: Generally you want to perform a search on a list. The ListView can be set on a RelativeLayout. On top of it you can set a View with the android:background=”@drawable/aShape”, which covers the entire ListView. The visibility should be “gone”. The drawable aShape is in my case a gradient with an alpha value.
The RelativeLayout:
<ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:drawSelectorOnTop="false"/> <View android:layout_weight="1" android:layout_width="wrap_content" android:id="@+id/list_search_overlay" android:layout_height="wrap_content" android:background="@drawable/search_overlay" android:visibility="gone"></View>
The shape (search_overlay in my case):
<gradient
android:startColor="#80000001"
android:endColor="#80000001"/>
Now onSearchRequested() must be overridden and set the View (in my case R.id.list_search_overlay) to visible. Finally a listener must be registered at SearchManager.setOnDismissListener() to set the View to visible again if the search dialog is closed.
The code (from the activity):
@Override
public boolean onSearchRequested() {
((View) findViewById(R.id.list_search_overlay)).setVisibility(View.VISIBLE);
final SearchManager searchManager = (SearchManager) this.getSystemService
(this.SEARCH_SERVICE);
searchManager.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss() {
((View)ServiceListBase.this.
findViewById(R.id.list_search_overlay)).setVisibility(View.GONE);
}
});
return super.onSearchRequested();
I hope this will assist you by optimizing the user experience with your app.
Cheers Mavi

You my comrade are a genius
My ideas exactly!
This is not a blur, it’s a basic alpha gradient. Useless article…