If an Android ActionBar is split into a top and a bottom portion using android:uiOptions="splitActionBarWhenNarrow"
in the Manifext.xml
,
is there a way to force some of the actions to be displayed in the top portion instead of having them all at the bottom?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
There's no standard way of doing this. That said, the Action Bar custom view will appear in the upper bar, so you can just use that. You will lose some of the extras (toasts on long press), so you'll have to implement them yourself. That said, of you're using ActionBarSherlock, all the layouts and styles for a normal button are there, so you can just use those.
Yes! You can continue to use
android:uiOptions="splitActionBarWhenNarrow"
in your Manifest.xml.You just also need to set:
Where
R.layout.custom_action_bar_top
would be a view that has all the buttons you wish to appear in the top action bar.All the menu items that you want at the bottom, should be added as usual in the
onCreateOptionsMenu
method of your activity.I would like to second Dylan Watson's solution, but with one improvement. For those who would like to keep the title, and not replace the entire actionBar with their new View, they use
getActionBar().setDisplayShowCustomEnabled(true)
, rather thangetActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
, as the latter will cause the new view to be the only view displayed in the actionbar. My code: