在操作栏中调整应用程序名称的大小 [英] Resize Application name in action bar

查看:110
本文介绍了在操作栏中调整应用程序名称的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我在操作栏中有4个按钮.我将android:showAsAction="always|withText"添加到xml文件中的每个item中,以强制显示所有4个图标. 我正在4.0屏幕上测试该应用程序,在垂直视图中,我在左侧看到该应用程序图标,该应用程序名称被剪切,然后我看到4个图标/按钮.例如,该应用程序名称为Pandemic,并且在操作栏中显示所有4个图标,我会看到Pan ...

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...

如何让应用名称文本resiz动态地填充在应用图标和操作栏上最左侧的图标之间?

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?

推荐答案

根据此

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. 使用android:showAsAction ="ifRoom | withText"代替"always | withText"
  2. 如果顶部没有足够的空间,请使用拆分操作栏允许Android在屏幕底部显示操作.它仍将在平板电脑大小的设备顶部显示操作.另请参见 http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
  3. 为标题使用自定义布局以缩小标题.我不建议这样做,因为它至少会隐式违反设计准则.如果您仍然想走那条路,则需要使用

  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))

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

要开始使用自定义布局,只需从SDK文件夹中复制一个正在使用的Android.

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

这篇关于在操作栏中调整应用程序名称的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆