android - Can not center the action bar title when the icon is shown -


the problem center action bar title , keep button @ same time. however, found title not center if icon shown. try align parent right , works, when try center in parent fail, still @ right of icon not @ center of action bar

fragment on create view:

 actionbar ab = getactivity().getactionbar();         ab.setdisplayshowcustomenabled(true);         ab.setdisplayshowtitleenabled(false);         ab.seticon(r.drawable.share_btn_home);         layoutinflater inflator = (layoutinflater) getactivity().getsystemservice(context.layout_inflater_service);         view v = inflator.inflate(r.layout.action_bar, null);         textview title = (textview) v.findviewbyid(r.id.action_bar_title);         title.settext(r.string.how_to_header);         ab.setcustomview(v);         ab.setdisplayhomeasupenabled(true);         ab.setdisplayshowhomeenabled(true);         ab.show(); 

xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <textview         android:id="@+id/action_bar_title"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerinparent="true"         android:ellipsize="end"         android:maxlines="1"         android:textcolor="@android:color/white"         android:textappearance="?android:attr/textappearancemedium" />  </relativelayout> 

thanks helping


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -