this question has answer here:
i developing application in customizing action bar shown in image:
my code follows :
// remove tabs actionbar getactionbar().removealltabs(); final viewgroup actionbarlayout = (viewgroup)getlayoutinflater().inflate(r.layout.custom_actionbar_layout, null); // set custom layout menus on actionbar getactionbar().setdisplayoptions(actionbar.display_show_custom | actionbar.display_show_home | actionbar.display_home_as_up | actionbar.display_use_logo); getactionbar().setcustomview(actionbarlayout); getactionbar().setbackgrounddrawable(new colordrawable(color.white)); getactionbar().setdisplayhomeasupenabled(false); getactionbar().setlogo(r.drawable.ic_back_orange); final textview textviewofactionbarheading = (textview) actionbarlayout.findviewbyid(r.id.textview_actionar_heading); textviewofactionbarheading.settext("my activity"); // getting reference of searchviewand textview of searchview searchview searchview = (searchview) actionbarlayout.findviewbyid(r.id.searchview_actionar_search); searchview.seticonifiedbydefault(true); final textview search_text = (textview) searchview.findviewbyid(searchview.getcontext().getresources().getidentifier("android:id/search_src_text", null, null)); // set color textview of searchview search_text.settextcolor(color.black); // set hint textview of searchview search_text.sethint("search"); // set hintcolor textview of searchview search_text.sethinttextcolor(color.dkgray); int searchimgid = getresources().getidentifier("android:id/search_button", null, null); imageview v = (imageview) searchview.findviewbyid(searchimgid); v.setimageresource(r.drawable.search_icon); searchview.setonsearchclicklistener(new onclicklistener() { @override public void onclick(view v) { } }); searchview.setonquerytextlistener(new onquerytextlistener() { public boolean onquerytextsubmit(string query) { return false; } @override public boolean onquerytextchange(string newtext) { if (textutils.isempty(newtext)) { } else { } return true; } }); searchview.setoncloselistener(new oncloselistener() { @override public boolean onclose() { } });
the issue is: action bar arrow getting padding or margin star shown in image :
try this
actionbar actionbar = getsupportactionbar(); actionbar.setdisplayshowhomeenabled(false); actionbar.setdisplayshowcustomenabled(true); actionbar.setdisplayshowtitleenabled(false); view customview = getlayoutinflater().inflate(r.layout.main_action_bar, null); actionbar.setcustomview(customview); toolbar parent =(toolbar) customview.getparent(); parent.setcontentinsetsabsolute(0,0);
Comments
Post a Comment