I have a sliding drawer menu in an activity, which has an actionbar with some tabs on it.
I'd like to get the sliding drawer to slide over the tabs , not below them.
This is what it looks like right now...
Any ideas on how this could be done?
Note: I understand that I might be breaking some conventions and UI patterns here, and if it does not work at all, I'll look at alternatives. But I'd like to get this working first.
EDIT: See the below screen shot of the Google Play Music app that does exactly what I need. See #CommonsWare's answer below where he does agree that I might be breaking convention. But then given the Play Music app, it may not be altogether that rare either.
you can use below libraries to get navigation model similar to Google play music app.
ActionBarSherlock (github)
nested-fragments (github)
PagerSlidingTabStrip (github)
NavigationDrawer (Android developer site)
Latest Support v4 library
I have created a project Navigation Drawer with Tab Strip Example at github, have a look at it.
Below is the screenshot of it.
Any ideas on how this could be done?
Do any of the following:
Switch away from action bar tabs, perhaps to ViewPager and a tabbed indicator (PagerTabStrip, TabPageIndicator from ViewPageIndicator)
See if an existing third-party drawer implementation has not yet updated to the new UI standards
Fork DrawerLayout and modify it to suit
Roll your own navigation drawer from scratch
I understand that I might be breaking some conventions and UI patterns here
Correct.
Check also this library http://www.androidviews.net/2013/04/pager-sliding-tabstrip/
The guy did a great job. You can use it with a navigation drawer and it works perfectly.
Finally, a clean way to achieve navigation drawer over sliding tabs in this blog
http://www.paulusworld.com/technical/android-navigationdrawer-sliding-tabs
This can be done WITHOUT a Third party library. Check out Google's Sliding Tabs samples
SlidingTabsBasic: http://developer.android.com/samples/SlidingTabsBasic/project.html
SlidingTabsColors: http://developer.android.com/samples/SlidingTabsColors/project.html
Also, check out this awesome link: http://manishkpr.webheavens.com/android-sliding-tabs-example/
Worked like a charm for me. :)
I had the same problem, but the only solution I found was to use tabs inside the inner fragment (not fragmentActivity). I don't know if it was the best solution, the only problem i had was styling this tabs, for the rest, it works perfectly
I managed to achieve this requirement by setting the navigationMode inside OnDrawerClosed and onDrawerOpened functions. It is a temp fix since the tabs actually do not disappear immediately.
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
if(getActionBar().getTabCount()>0) //Add tabs when the fragment has it
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
...
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
..
}
If you have some fragments with tabs, and other without it don't forget to remove tabs onCreateView of fragment that does not have tabs.
getActionBar().removeAllTabs();
Actionbar Navigaton Drawer and SwipeTabs cant be used simultaneously. You should implement Navigation Drawer using Actionbar and swipetabs by simple Tabhosts. You can use Tabhost for tabs and use fragments for inside view of each Tab. Fragments should be used via viewpager to provide scrolling/swiping effect. Connect tabs and viewpager with eachother through their methods
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabHost
android:id="#+id/tabHost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/viewPager_home"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
</TabHost>
Play music does not use standard ActionBar.Tab
Then you can implement your own tab container by extend HorizontalScrollView
and work together with ViewPager
I have use tabs inside fragment of drawer.
I solve this problem adding
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
in onDrawerClosed() and getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); in onDrawerOpend() method.
I hope this will help you.
Related
In Navigation 2.1.0-alpha03 they added functionality to navigate to a DialogFragment with <dialog> tag.
However, how can the source fragment/activity then dismiss this dialog fragment? Its very easy to do this in pure AOSP android with dialogFragment.dismiss(), but I don't see an accompanying way in Navigation library.
findNavController().navigateUp() is the one what you are looking for.
<dialog> is treated same as <fragment>. Controlling destinations are all identical.
How can I create a settings menu for my application that let's me show more information about the current status? With the menu layout it appears that I can only set these attributes:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/bot_engine"
android:title="#string/menu_settings_bot_engine" />
<item
android:id="#+id/text_to_speech"
android:title="#string/menu_settings_text_speech" />
</menu>
And It displays as follows:
But I want something like this:
This is how Google Glass display It's settings menu.
I want the user to be able to tab over the settings to toggle them between (Active/Inactive), displaying a message:
Active (In green) or Inactive (in red).
How can I do that?
The GDK menu works in the same way as the android context menu's on a phone.
It's designed for simple menus with just text and an optional icon. If you want to do something more complex (Like the glass settings) you would need to use a CardScrollView and add your own cards to it, then you can have as much flexibility as you like.
Hope that helps.
I would like to write under the text in the action bar so i use this xml:
<item
android:id="#+id/Home"
android:icon="#drawable/ic_action_home"
android:showAsAction="always|withText"
android:title="home"/>
<item
android:id="#+id/Refresh"
android:icon="#drawable/ic_action_refresh"
android:orderInCategory="100"
android:showAsAction="always|withText"
android:title="refresh"/>
although i write:
android:showAsAction="always|withText"
this what i get :
How could I write text under the icons ?
'always|withText' only works if there is sufficient room. Else, it will only place icon. In your case, you've got several icons there which does not leave any spare room for text.
You've got two options:
Reduce the icons by moving them either to an overflow menu or somewhere else in your UI.
Design images which consist both icon and text and use them as your icons.
Edit: Well, here's a lot better answer: https://stackoverflow.com/a/12225863/2511884
I am working on soft keyboard. I had done with all of my functionality.
But now i just need to change view of key preview when key is
pressed. Currently my key preview is shown(default sample keyboard key
preview) like shown in below image,
As we can see character 'd' is popped up when key is pressed.
But now i need customize it. As currently key preview background is
white, i need it to set green color just like shown below,
I have the sample keyboard code, but couldn't find the place where it
show a popout letter. So i can easily edit it customize it my own way.
I googled for help nothing found any help any. Any help is
appreciated.
Use something like this in your keys XML layout:
<Key android:codes="97" android:keyIcon="#drawable/key_icon" android:iconPreview="#drawable/key_preview_icon" />
It worked for me. I hope this helps you :)
You may have created a android.inputmethodservice.KeyboardView.xml layout resource file
Use android:keyBackground="#FF419F3C"
<?xml version="1.0" encoding="utf-8"?>
<android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="#+id/keyboard"
android:labelTextSize="20dp"
android:background="#color/colorTrybg"
android:keyTextColor="#color/colorTrykey"
<!-- This one -->
android:keyBackground="#FFFFFF"
android:layout_alignParentBottom="true"
android:keyPreviewLayout="#layout/preview">
</android.inputmethodservice.KeyboardView>
Is anyone using MGSplitViewController inside a UITabBar?
My objective is basically to use UISplitViewController inside a UITabBar. UISplitViewController doesn't work well inside a UITabBar. Specifically, UISplitViewController splits apart when device orientation changes.
Since UISplitViewController didn't work for me, i turned to MGSplitViewController. And now it seems that it's not a workable solution to be used with UITabBar either. Im running into all sorts of problems. Mainly the following:
I have a tab-bar with 3-4 tabs. Each one contains a MGSplitViewController. In general, the MGSplitViewController contains a Master (UINavigationController) and a Detail (UIViewController). When i rotate the device, the content (UITableViewCell) inside the UITableView is misaligned/disturbed. Scrolling the UITableView to show new cells fixes the misalignment. The Master has a Navigation bar and a search bar, and orientation change doesn't affect them. Any solution?
MGSplitViewController is great! But it's not being maintained.
I ended up using IntelligentSplitViewController (github.com/grgcombs/IntelligentSplitViewController). Worked for me!