How to find the width of different icons present in system Action Bar in android -
i need resize search space when expand on click in action bar , need know empty width present in action bar. didn't find way detect empty space in action bar.please me
the title of action bar got shrink when click on search icon, fix issue need set maxwidth search icon ( when expand ) , set maxwidth need empty space in action bar.
--> tried collapseactionview, giving text instead of icon.
public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.split_pane_menu, menu);
mactionbarmenu = menu; menuitem searchitem = menu.finditem(r.id.split_pane_search); msearchview = (searchview) searchitem.getactionview(); ***msearchview.setmaxwidth(500);*** <----- set value , need know how free space there in action bar ---- ---- }
please me out
if specify menu action elements in xml, can assign ids each one. in code can grab reference views findviewbyid.
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" android:showasaction="ifroom" /> <item android:id="@+id/action_settings" android:title="@string/action_settings" android:showasaction="never" /> </menu>
instead of determining remaining space in actionbar, might able set item's layout_width "match_parent" or "fill_parent" , achieve same effect.
Comments
Post a Comment