How do I hide the ActionBar as a user scrolls down a View?
I just created a sample activity from Android Studio's default "Tabbed Activity" using navigation style "Action Bar Tabs (with ViewPager". From there, if a user swipes down one of the tabs, how can I implement that effect of hiding the ActionBar and then pulling it back down when the user scrolls up? (Just like Google Play app does).
EDIT:
One of the tabs has a RecyclerView with some Views inside. It scrolls vertically. So you can read this as: how to hide the ActionBar as I scroll down this RecyclerView?
EDIT 2:
Visually, I'm trying to achieve this:
try this
getSupportActionBar.hide(); // if it extends action bar activity
or
getActionBar.hide();
Related
I have a screen with TabLayout (Using Android Design Support library) at the top and a ListView below it. I don't have any Action Bar.
Whenever I select one or more Items of ListView I show Contextual Action Bar to perform some operations on selected rows. The CAB is shown above TabLayout. It seems like whole screen is shifted downwards which is not a good user experience. I want to show the CAB in front of TabLayout. The tabs should be behind CAB.
Below is my expected output:
Please help me out. How can I show CAB in front of TabLayout?
Set android:windowActionModeOverlay to true in your theme. If you're using the AppCompat library, set windowActionModeOverlay in your app's attribute namespace to true.
I'm using one activity as a container and multiple fragments. Some of the fragments need to display app bar, some don't while others require to show a special app bar (e.g. an app bar that shrinks when swiping up). So where should I put the app bar (or action bar), in the activity or in the fragments?
By the way, if I put the app bar inside the fragments, how should I manage the app bars properly when fragments come in or move out?
if every fragment should have a different app bar, you probably want to use a Toolbar.
Toolbar is a standalone ActionBar that you can put anywhere, in any view group. The Toolbar API is roughly the same as the ActionBar one, so you should not have any major issue migrating to Toolbar.
For your app, you should have Toolbar in every fragment, when needed and every fragment control it's own Toolbar.
i am developing an android application that contains tabs. my application is like this:
Please notice that I have an action bar that contains many tabs.
Now I want to add an extra tab bar. what i mean is: in the players activity i want to have anotion action bar. for example players under 21 years and players above 21 years
how can i do that please?
what i have tried
i tried manking many bottons with view pager. and when the user press on any button, i slide the view pager. it works good. but i would like to know if there is a standard solution.
hint
i think that action bar at the top and ation bar at the botton will help. but i don't know if this is available.
thank u very mush.
The framework provides TabHost, which you can bind to the ViewPager from by setting an OnTabChangedListener and changing the current page based on the selection. It's slightly more complicated than just using buttons, but you get the tab theme
I am using both actionbarsherlock and slidingmenu objects
the point is, I want my menu - which is sliding to do the following
push the currently visible screen aside, along with its actionbar
the fragment that is displayed inside the menu to have a different actionbar
how do i do that?
I've set everything to make 1 work
but the fragment is missing the menu - how to add it ?
You can't have multiple ActionBar in the same activity.
Best thing you could probably do, is not make the ActionBar slide with the menu, while starting/finishing an ActionMode when you open up/close the sliding menu.
Or if you really want to slide the ActionBar, then simply create a view in the menu fragment that will looks like an action bar.
You probably can use a custom layout in your actionbar and manipulate it by adding an animation so that it looks like the actionbar slides out and it is pushed by another actionbar when the menu slides in. The object would be the same, but the user perception will be of a sliding action bar pushing away the previous one.
For my application , I'm planning to have a design as this:
http://img811.imageshack.us/img811/7045/problemel.png
-Design needs to have a title bar which is indeed the action bar in android. To overcome the compatibility issues, I used the sherlock action bar which is said to support older versions that dont have action bars. I havent tested yet for the older devices however.
-As far as I know, for navigation , we could rather use tabbed or dropdown list methods. I want to have constant tabs for every page in my app to stand below the page. This reflects the tabbed action bar, however I want it below not just under the action bar. I don't know how but youtube application somehow has it in the middle of the screen (if it's not a custom view). So how do we have tabs positioned in the bottom of the page?
-Also I want to have another menu, whose items depend on the page it's on. But the apperance will be the same for every page. In the picture on the left this menu has buttons as "Bt 1" ,"Bt 2". I dont want to repeat the same xml for every activity page, but I'm not sure how to achieve it without repeating. If the action bar allowed using both navigation tabs and the drop down list, I could put the items of this menu in the dropdown list just as the picture on the right (onto the gray button). But I guess it does not?!
Therefore I have to repeat the menu xml code in every page or is there another smart way?
Any advice will be appreciated.
This can be achieved not with tabs but by adding items to a linear_layout with a gravity of bottom but it is a bad practice as #D_Steve595 stated and should be avoided in android designs.
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);