Just getting opinions here. My app has a toolbar below that are tabs. In the toolbar, there is a SAVE button where I want it to be visible ONLY when certain tabs are in "focus". I accomplished this by setting the menu item to static in the main activity and setting it to visible when the fragment is in "focus". Any downside to doing it like that? Will this cause large overheads?
Related
I've read this question and watch the video clip from Bitspin, however I'm still unable to figure out the techtique they used on ActionBar.
You can observe the ActionBar layout transition inside Timely, when navigating from the settings Fragment to the about Fragment (and navigating back), the up caret and the title is animated by zooming and fading. So how is this made possible?
Or can you let me know if there is some techtique on crossfading ActionBar layout changes? My main purpose is to smooth the transition when user opens the navigational drawer and the title changes, aciton buttons disappears.
Thanks in advance.
EDIT:
I turned on the dev options for showing layout borders and found that Timely is using custom layouts to achieve this. However this is not possible for other applications heavily relying on other ActionBar features such as ActionMenu.
So are there any alternative ways to achieve layout transitions on ActionBar and its ActionMenus?
I have an activity contain an tabhost. And I use several fragments for the tabhost, each tab only has one fragment, that means the fragment size is matching the parent. However , not all fragment has actionbar.
For example, the first one hide actionbar while the other show the actionbar.
The problem is , when I show / hide the actionbar, it does not transacts instantly, but it has an amination that e.g. for the case hide->show , the actionbar is hide and leave a blank space on the screen , then the content screen will expand to fit the screen . It cause some "glitch" in the ui , so are there any way to fix it?
I tried requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);
Which the animation is hide but the actionbar is overlay the content instead of a part of the content,
Update:
The overlay of actionbar is like this screenshot , it is on top of the content. please have a look
Please see a work around here for requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);
Using ActionBarSherlock; experiencing View.getLocationOnScreen() inconsistency between 2.2 and ICS/JB
Also for the hide and show method can you please confirm if you are calling it within onCreate method of your fragment?
Could you post the code where you are making the call?
I've set up a ViewPager in my App with tabs, but I need to position the tabs underneath a button so the layout would be
TitleBar
Button to search activities on a day
Tabs of each day there are activities
Is that kind of layout possible to do using Tabs or will I need a different approach to solve this?
The way the activity is running is theres a main activity, and the layout is just the button and a FrameLayout, and the the list (where the ViewPager is) is set up in a fragment and the fragment is loaded into the FrameLayout. I don't know if this is the best method for this so if not please add your recommendations of a better method I could use.
EDIT: If I could get it so all the tabs were at the bottom of the screen this would also be fine.
Is that kind of layout possible to do using Tabs
Not with action bar tabs. Not only can you not control where the tabs go, you cannot even control if there will be tabs versus a drop-down list.
will I need a different approach to solve this?
You are welcome to use some other tab solution (ViewPager with a tabbed indicator, FragmentTabHost, etc.) where you have more control.
Note that your proposed design does not adhere to Android design aesthetics. Most apps would not have "Button to search activities on a day", but instead a search action bar item, or perhaps a SearchView in the action bar.
If I could get it so all the tabs were at the bottom of the screen this would also be fine.
This is completely against the Android design guidelines. Don't use bottom tab bars on Android.
So I'm working on adding ActionBarSherlock and the Navigation Drawer to a project that previously implemented a custom (very poorly written) "action bar". Instead of using fragments and a backstack of activities for navigation, some activities show and hide different layouts. (That is, suppose I am in a list mode and then select a button to go into an edit screen. The app currently hides the list layout and shows another layout.).
So I've added actionbar sherlock and a navigation drawer to all the activities. I want to be able to programmatically switch the navigation icon from the 3 lines to the arrow when certain buttons are pressed.
I can't figure out how to do this though. Any ideas?
Thanks!
The solution to this problem is to use the method:
setDrawerIndicatorEnabled(boolean enable)
inside the ActionBarDrawerToggle class.
After:
drawer.setDrawerListener(toggle);
Use this code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.select);
It depends how wedded you are to built-in actionbar artifacts. You can always redraw the current actionbar by inflating a layout of your choosing, then calling
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
// Inflate and do whatever you need to your view...
getSherlockActivity().getSupportActionBar().setCustomView(abView);
getSherlockActivity().getSupportActionBar().show();
When you want to go back to your standard (assuming you're using a DrawerLayout to do your navigation drawer), you can just set make a call to setDisplayShowCustomEnabled(false) (re-enable showHome and showTitle as you please).
As far as I know, customization of the back button can only be done via themes. Besides, swapping the drawer icon for the back icon (within the same Activity) doesn't make sense, since users would still be able to access the navigation drawer by sliding the left most edge to the right. It just wouldn't make sense.
If you absolutely need the back icon, then it would make the most sense to make that screen a new Activity since you would indeed be adding another "level" to the stack, which is what the back icon represents.
I'm using a ViewPager to scroll between different fragments. There are two types of fragments, using two different menu resources. I'm invalidating the menu to switch between those resources when necessary. That's all working pretty well, but the menu is "redrawn" without an animation.
To prevent having to mess with individual MenuItems I was hoping I could briefly hide the ActionBar while the new menu is loaded, showing it when that's done. That's working as expected as well, but the activity is resized when the ActionBar is toggled.
Is there any way to prevent this from happening, or otherwise hide the ugly transition between menu resources?
I didn't quite catch the menu part of your problem, but there is an easy solution to preventing your activity from resizing when the ActionBar appears or disappears.
You can tell the ActionBar to draw itself in overlay mode, meaning it will float on top of the activity, in stead of actually being part of the activity's layout. Use either android:windowActionBarOverlay in your theme, or the Window.FEATURE_ACTION_BAR_OVERLAY flag from code.
You probably want to use this feature in conjunction with the actionBarSize constant, that specifies the correct offset for the first view in your layout. This way, your content still appears below the ActionBar, but since the ActionBar itself is an overlay, upon hiding/showing it, the activity will not resize.
<SomeView
...
android:layout_marginTop="?android:attr/actionBarSize" />
More details can be found in the documentation.