Reputation: 7037
Simple aim:
To have default buttons in the navigation bar of my ActionBar
with the text centre aligned. I simply want to use the default, simple way of:
ActionBar.Tab myTab = Actionbar.newTab()
myTab.setText("my tab's text");
What's the problem
I cannot find any simple way to do this whatsoever. You can't access the views (as ActionBar.Tab.getCustomView()
always returns null
due to it being the default view). There is no method that I can see in ActionBar
, ActionBar.Tab
, etc to get the current view, get or modify LayoutParams
(especially Gravity
). A visualisation of the problem is below (one line seems to work right, but double lined navigation buttoms definitely seem left aligned):
Unideal solution
Am I right in negatively thinking that the only way to accomplish this is to use custom views for all of my tabs, somehow guess / attempt to copy the default formatting for the tabs (as I can't find anyway to access these views) and assume / hope that the default formatting / font / style of ActionBar.Tab
's text does not change any time soon?
Surely there has to be a better way?
Upvotes: 3
Views: 589
Reputation: 1411
please download the follwing example. it will help you. i am sure i take help from this demo. https://github.com/JakeWharton/ActionBarSherlock
Upvotes: 0
Reputation: 7533
AFAIK, there's no way you can access the Views
in ActionBar
. Using custom layout seems the only solution. However, doesn't Android align the text to center automatically? It apparently does so in all my applications.
Upvotes: 2