android - action bar compact height changes when searchitem expand -
i have list fragment
in baseactivity
, want implement search functionality. action bar compact
height changes while click on search item button
see below screenshot
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.android.bypeople.uber.baseactivity" > <item android:id="@+id/action_add" android:icon="@drawable/btn_profile_selector" android:orderincategory="100" android:title="@string/action_add" android:visible="false" app:showasaction="always"/> <item android:id="@+id/action_search" android:icon="@android:drawable/ic_menu_search" android:title="@string/action_search" android:visible="false" app:actionviewclass="android.support.v7.widget.searchview" app:showasaction="ifroom"/>
oncreateoptionsmenu in fragment
@override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { super.oncreateoptionsmenu(menu,inflater); inflater.inflate(r.menu.base, menu); menu.finditem(r.id.action_add).setvisible(true); searchmanager searchmanager = (searchmanager) getactivity().getsystemservice(context.search_service); menuitem searchitem = menu.finditem(r.id.action_search); searchitem.setvisible(true); searchview searchview = (searchview) menuitemcompat.getactionview(searchitem); searchview.setsearchableinfo(searchmanager.getsearchableinfo(getactivity().getcomponentname())); searchview.setonquerytextlistener(querylistener); querylistener = new onquerytextlistener() { @override public boolean onquerytextchange(string newtext) { return false; } @override public boolean onquerytextsubmit(string query) { toast.maketext(getactivity(), "searching for: " + query + "...", toast.length_short).show(); return false; } }; }
refer link too.!!
resolved issue after lots of search , found something.
may too.!!
after add attribute in toolbar
android:layout_height="?attr/actionbarsize"
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" style="@style/toolbarstyle" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@color/myprimarycolor" android:minheight="@dimen/abc_action_bar_default_height_material" > <textview android:id="@+id/toolbar_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="18sp" android:textcolor="@color/mytextprimarycolor" android:layout_gravity="center" /> </android.support.v7.widget.toolbar>
Comments
Post a Comment