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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -