I know that I could hide and show ABS like:
getSupportActionBar().hide();
getSupportActionBar().show();
However this makes it hide and show with animation and I don't like it. I need it to hide and show immediately like if set visibility property to its view (View.VISIBLE/View.GONE/View.INVISIBLE). How could I achieve that? Or is there a way to hide()/show() without animation (show()/hide() doesn't accept any parameters)? Or is there a way to get ABS view so I could use setVisibility() on it?
No, you can not disable Actionbar show/hide animation.
Related
I have an app, which have an action menu item on the right (2).
I need an ulterior menu in the left(1) or a button in the action bar, is that possible?
I attach a image.
enter image description here
You may create a custom toolbar. The standard height of a toolbar is 89dp.
To create a custom toolbar you should make your activity view container RelativeLayout. Then create a custom toolbar view (it may also be RelativeLayout) which height is 89dp. Then add your toolbar to the main container and set alignParentTop to true. So you have a custom flexible toolbar and you can add any view to it.
This way is very comfortable to use any custom views on your toolbar.
I also faced the same situation of customizing action bar. After a lot of searching I got the solution which is Toolbar.
Checkout: https://developer.android.com/training/appbar/setting-up
I think from now on, you should start using Toolbar as the default action bar for your apps. It provides high level of customization and material design features.
When I call toolbar.startActionMode(...) it defaultly see a fade animation, I would like to change that to a slide animation. As I can just touch the Toolbar view directly, I don't know how to do this.
I can do this by using 2 toolbars and just animate the second one. But as the Toolbar provides an action mode and I already use it, I would like to know if I somehow can modify it's animation...
Android doesn't give you access to the ActionMode "toolbar". Which by the way is not a Toolbar. The type of the context "toolbar" is ActionBarContextView.
If you want full control you need to implement your own Action Mode with 2 toolbars. Then u can add the animation you desire.
I'm using ViewPager to display tabs in Android, but in a circumstance, I want to display a fragment on top of the pager/tabs, but NOT on top of the ActionBar. If I hide the action bar, they both disappear. If I don't do it, I can't find a way to get rid of pager's tab bar (or whatever it's called). Here is a visual representation of what I'm trying to achieve:
How can I hide that bar without hiding the action bar?
I think you can do it by setting a new navigation mode.
Use setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD) to hide them
Use setNavigationMode(ActionBar.NAVIGATION_MODE_TABS) to show them again
Edit:
Please note that the setNavigationMode methods are deprecated in Android Lollipop.
Reference
Use this to get rid of tabs in actionbar
setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD)
I have a custom video player,when user enters into fullscreen i am hiding actionbar but due to its animations its being delayed.
how to avoid it in normal ActionBar or SherlockActionBar ?
I recommend to make use of Material Design with the new support library. By doing so you can replace your ActionBar with a Toolbar which gives you a lot more control. By using the Toolbar you can achieve your goal with the setVisibility() method.
I'm developing an application in which I have to put drawables on top of the actionbar and have to update then from time to time. Here is a layout what I want it to look like.
I want to put a drawable as shown in the picture atttached(The green color drawable not the notification thing). Is that possible to achieve this kind of screen in android? If, so please guide me how to achieve this.
Any kind of help will be appreciated.
This is easy using a custom view. Let me explain you the steps briefly:
Create your custom view in the layout folder. For example, an ImageButton.
Set this view as the custom view of the action bar in your activity. You can do this by calling
getSupportActionBar().setCustomView(R.layout.your_custom_view);
(or getActionBar() instead of getSupportActionBar())
Call setDisplayOptions() with the ActionBar.DISPLAY_SHOW_HOME and ActionBar.DISPLAY_SHOW_CUSTOM options.
If you have other standard buttons in the action bar, inflate the menu.
You can finally set the OnClickListener for your custom view.
This worked for me, hope it helps you!
Create custom view
Use it as ActionView in ActionBar
In onCreateOptionsMenu get a reference to your view and update it when needed