Is there any way to create custom actionbar like below screen, using actionbarsherlock library
相关问题
- 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
Here is how you actually do it in xml
use Roman's layout in Honeycomb and above
/layout-v11/actionbar_custom_view_done_discard.xml
/layout-v11/actionbar_discard_button.xml
/layout-v11/actionbar_done_button.xml
and backport it with ActionBar Sherlock
/layout/actionbar_custom_view_done_discard.xml
/layout/actionbar_discard_button.xml
/layout/actionbar_done_button.xml
You should be able to accomplish this via
setCustomView()
. Roman Nurik has a G+ post on ways of implementing DONE+DISCARD, with source code available. While his code does not use ActionBarSherlock, I suspect that it will port over.However, bear in mind that button backgrounds look a bit different on Android 2.x than on 3.0+, and so you may need to do a bit more work to get your buttons in the action bar space to look the way that you want.
To complete the usage instructions @Vlasto Benny Lava has described, here's the code that actually sets the ActionBar (based on the original code for API 14 by Roman Nurik) -- adapted for ActionBarSherlock usage.
I use it for a
Fragment
hence thegetSherlockActivity()
. If used inActivity
, you can freely omit that part.There are two places where you can setup this custom ActionBar:
in Activitys
onCreate()
(or in FragmentsonAttach()
),in Activitys/Fragments
onCreateOptionsMenu()
.On procedure how to revert the ActionBar to the "original" form (after the DONE or DISCARD was selected), you can refer to this answer.