我怎么能这样做?我通过这个XML实现了以下ActionBar:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_gps" android:icon="@drawable/icone_gps_continu" android:showAsAction="always" android:title="@string/menu_gps"/> <item android:id="@+id/menu_sort" android:icon="@drawable/icone_liste_chron" android:showAsAction="always" android:title="@string/menu_liste"/> <item android:id="@+id/menu_stats" android:icon="@drawable/icone_statistiques" android:showAsAction="always" android:title="@string/menu_stats"/> <item android:id="@+id/menu_save" android:icon="@drawable/icone_terminersortie" android:showAsAction="always" android:title="@string/menu_save"/> <item android:id="@+id/menu_search" android:icon="@drawable/ic_launcher" android:showAsAction="always" android:title="@string/menu_search"/> <item android:id="@+id/menu_photo" android:icon="@drawable/icone_enregistrerphoto" android:showAsAction="always" android:title="@string/menu_photo"> </item> <item android:id="@+id/menu_sound" android:icon="@drawable/icone_enregistrerson" android:showAsAction="always" android:title="@string/menu_sound"> </item> <item android:id="@+id/menu_settings" android:icon="@drawable/icone_parametres" android:showAsAction="always" android:title="@string/menu_settings"> </item> </menu>
我当然通过将android:uiOptions =“splitActionBarWhenNarrow”添加到我的< application>来启用拆分ActionBar.清单中的标签.
我得到的是一个空的“顶级”ActionBar;而底部只显示三个图标.我认为我可以在portait模式下在顶部显示3-4个图标,在底部显示5个图标,并且所有这些图标都在横向模式下显示在顶部.
注意:即使我使用Galaxy Nexus在ICS上进行测试,我也使用ActionBarSherlock来提供向后兼容性.
解决方法
重复:
> How to Place ActionBar Items in Main ActionBar and Bottom Bar
> Android Split Action Bar with Action Items on the top and bottom?
显然这是不可能的.然而他们在gmail / gplus中做到了,也许使用底部的自定义视图……仍然期待更好的答案!
I think the problem with splitting the actions between the top and bottom is that it would make it more difficult to perform actions. Actions should be the most important things to do on an Activity — splitting them between the top and bottom of the screen means users need to look in two places rather than one.