Always show full title in ActionBar

I have an ActionBar with a logo, title, three tabs and one action.

In portrait mode, everything looks good, because the tabs move to a complex ActionBar, for example: __ _______________
# My title ยค
_ ________________
Tab 1 | Tab 2 | Tab 3
__ _______________

But in landscape mode, the title is truncated because the tabs move to the top bar of the ActionBar, for example: __ ________________________
# My ... | Tab 1 | Tab 2 | Tab 3 | ยค
__ ________________________

Anyway, can I tell the ActionBar that the title should never be truncated? If not, can I at least set the width of the header? (This is normal for me if the tabs move to a complex ActionBar even in landscape mode)

EDIT:

Code requested. Here he is:

public class MyActivity extends SherlockFragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = super.getSupportActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle("My Long Title"); actionBar.addTab(actionBar .newTab() .setText("Tab 1") .setTabListener( new TabListener<MyFragment>(this, "tab1", MyFragment.class, null))); actionBar.addTab(actionBar .newTab() .setText("Tab 2") .setTabListener( new TabListener<MyFragment>(this, "tab2", MyFragment.class, null))); actionBar.addTab(actionBar .newTab() .setText("Tab 3") .setTabListener( new TabListener<MyFragment>(this, "tab3", MyFragment.class, null))); } } 
+8
android android-layout android-actionbar
source share
1 answer

I think that if you want a fixed header, then in the menu folder you will have an xml file, for example

 <menu xmlns:android="http://schemas.android.com/apk/res/android" > <group android:id="@+id/group" > <item android:id="@+id/menu1" android:orderInCategory="100" android:showAsAction="ifRoom" android:title="@string/menu1"/> <item android:id="@+id/Search" android:actionViewClass="android.widget.SearchView" android:icon="@drawable/ic_action_search" android:orderInCategory="100" android:showAsAction="always" android:title="@string/menu3"> </item> <item .............. </item> </group> </menu> 

In the above android: showAsAction code plays a vital role. If you want any item to always be displayed, you should use android: showAsAction = "always". This will definitely solve your problem.

I have not used SherlockFragmentActivity, but I think this can help you a lot.

I suggest you process this through your xml file of your menu folder with the following processing in your java.Code file as follows: In your onCreate (), try the following: -

 setContentView(R.layout.activity_action_bar_eg);//this is the xml file name inside the menu folder getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayShowTitleEnabled(false); ActionBar bar=getActionBar(); bar.show(); 

With these changes too for your problem Solution

 @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_action_bar_eg, menu); } 
0
source share

All Articles