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.
Related
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();
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 want to have two menus in my android app. First one is search icon in ActionBar (at the top) and second is a TextView and pop up item at the bottom. How to achieve it? I tried android:uiOptions="splitActionBarWhenNarrow" but it moves all the menu items to bottom. Please help!
Android has not made this possible on purpose, the action bar at the bottom (called the split action bar) only has the purpose of giving extra room for actions if it is necessary (hence the uiOptions name "splitActionBarWhenNarrow").
You could still get the desired result by manually creating a split action bar by adding a LinearLayout at the bottom of your View, and using a PopupMenu for the menu.
I am using Action Bar in my application to implement Tab Fragments. I am successful in it. But getting a small problem. I am in a need of a drop-down list at the Right Corner of the action bar and a search button. Please see the image:
You can see the red marked buttons that i need to show in Action bar and below the actionbar we have tab fragments. I am successful in generating the Fragments but getting problem in showing these buttons on Actionbar. Please help me
The overflow button is automatically generated but if you have a phone with hardware button it wont show up. You shouldn't try to force it to show up as it goes against ussual behaviour for people with phones that have a hardware button.
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);