I have one header layout looks like this.
Now on on the very next of the right side of the button i want to add this image and try to used the Collapsible SearchView without using action bar means i want to apply the same effect of action bar search view on my layout header.
More over I also want to remove the Name and icon of the app which comes above the header.
Any Idea how to achieve this??
your help/suggestions will be appreciated...
Thanks in advance...
EDIT ::
what i have tried so far is ...
this is the my header.xml
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<RelativeLayout
android:id="@+id/layout_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/topbar"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal" >
<Button
android:id="@+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/previous" />
</LinearLayout>
<TextView
android:id="@+id/tv_headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center|center_vertical|fill_horizontal"
android:text="Home"
android:textColor="#FFFFFF"
android:textSize="20dp"
android:textStyle="bold" />
<Button
android:id="@+id/btnLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/logout" />
<ImageButton
android:id="@+id/imgSearch"
style="@style/Widget.Sherlock.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btnLogout"
android:src="@drawable/ic_search_inverse"
android:title="Search" />
<com.actionbarsherlock.widget.SearchView
android:id="@+id/searchView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tv_headerText"
android:layout_marginTop="10dp"
android:layout_toLeftOf="@+id/imgSearch"
android:background="@drawable/ic_search_inverse"
android:visibility="gone" />
</RelativeLayout>
</merge>
search_menu.xml
<item
android:id="@+id/action_search"
android:actionViewClass="android.widget.SearchView"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="always"
android:title="Search"/>
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<!-- header Part -->
<include layout="@layout/header" />
<!-- header Part is over. -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="None"
android:textColor="@color/black"
android:textSize="25dp"
android:textStyle="bold"
android:visibility="gone" />
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="@+id/et_productSearch"
android:cacheColorHint="#00000000"
android:scrollbars="none" >
</ListView>
</RelativeLayout>
</LinearLayout>
in My Home.java
ImageView imgSearch;
SearchView searchView;
imgSearch=(ImageView)findViewById(R.id.imgSearch);
searchView = ((SearchView)findViewById(R.id.searchView));
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
searchView.setVisibility(View.INVISIBLE);
return false;
}
});
my OnOptionItemSelected ::
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_search:
if (searchView.getVisibility() == View.VISIBLE) {
searchView.setIconified(true);
searchView.setVisibility(View.INVISIBLE);
} else {
//searchView.setMaxWidth(searchView,getWidth() - imgSearch.getWidth());
searchView.setVisibility(View.VISIBLE);
searchView.setIconified(false);
}
break;
}
return true;
}