Resize Application name in action bar

∥☆過路亽.° 提交于 2019-12-11 11:53:39

问题


In my application I have 4 buttons in the Action Bar. I added android:showAsAction="always|withText" to each item in the xml file in order to force show all 4 of the icons. I am testing the app on a 4.0" screen, and in vertical view I see the application icon on the left, the app name is cut, and then i see the 4 icons/buttons. For example, the app name is Pandemic, and with all 4 icons in the action bar, i see Pan...

How can I have the application name text resiz to dynamically to fill between the app icon and the left most icon on the action bar?


回答1:


According to this http://developer.android.com/design/patterns/actionbar.html (search for "How many actions will fit in the main action bar?") you should show but 2 actions on a 4" display. Of course you can show more actions but then you run into the problem you encountered. Also these recommendations are design guidelines and it makes sense to follow them to offer a good user experience. Having four buttons next to the title makes the action bar too crowded IMO.

I see a couple of options you can pursue:

  1. Use android:showAsAction="ifRoom|withText" instead of "always|withText"
  2. Use a split action bar to allow Android to show the actions at the bottom on the screen if there isn't enough space at the top. It would still show the actions at the top on tablet sized devices. See also http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
  3. Use a custom layout for your title to make the title smaller. I wouldn't recommend this because it would violate the design guidelines at least implicitly. If you still want to go down that path you need to create your own layout for the title using

    actionBar.setCustomView(newTitleBar, new ActionBar.LayoutParams(Gravity.LEFT))

To start with a custom layout just copy the one Android is using from your SDK folder.



来源:https://stackoverflow.com/questions/15454859/resize-application-name-in-action-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!