I was trying to add 5 items to the bottom navigation view , But when i add icons the view get collapse . each icon doesn't get ideal width which means the same width . please refer to the image , Any reason for this ?
Edited :- This seems like the default behaviour, If i press on something the button gets the focus
But is it possible to show it like iOS which means each tab having the same width ?
In the bottom navigation material design specs there is a section describing "fixed" vs "shifting" modes
While this doesn't appear in the official bottom navigation view documentation (ahem google), if you look at the source code you will see that there is the ability to set the "Shifting Mode" both via xml and java.
Please note that I haven't tried this and am basing it on the source code alone.
Related
I want to create a bottom navigation bar in my Android project. Here are 5 items(just items icons. No name of any item) in the navigation bar. I want to make it in a way so that when an item is selected it is magnified a little along with showing its name.
How can I do this?
P.S. - I instead tried with an imageview inside of which there are imagebuttons. One non-magnified icon imagebutton and the corresponding magnified icon (+ its name) imagebutton are overlapped, setting one visible and other invisible alternatively, but it was a bad idea. The code works but the layout is very bad and messy.
Answer with Tip:
Answer:
That's the default behavior if you use the latest support:design library and then implement your BottomNavigationView. As stated in my comment above; below your question.
Some links to implement Bottom Navigation View (which you would have easily got if you would have googled for them):
1] How to Code a Bottom Navigation Bar for an Android App
2] Android Working with Bottom Navigation
Tip:
But the problem with the knowledge gained from the above links is; Material Design documentation tells us that if the Bottom Navigation has:
3 items — we should display the icon with text (always) for all items.
4–5 items — we should display text for active icon only and hide for inactive items (or views).
Now, you might have a good guess on what I’m going to say next.
“This is what the Material Design guidelines suggest, so let’s just do this.”
But this time I won’t. I disagree, and so should you. I’ll tell you why.
The Material Design guidelines aren’t always right.
Whether you have 3 or 5 items in your Bottom Navigation, ALWAYS show
text labels!
By doing so, you’ll avoid the Mystery Meat Navigation problem that plagues Material Design. Shoutout to Teo Yu Siang for making aware of this!
Buttons or links that don’t explain to you what they do. Instead, you
have to click on them to find out — Mystery Meat Navigation.
I’m sure we’ve all been victims of this at some point at least. We click on a button assuming it to do something, only for it to do something else entirely!
So do yourselves, and your users a favor. Always, show text labels for your Bottom Navigation icons.
By mentioning this (for instance): bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
I did my part to give good UX. Rest all depends on you.
Tip -- Source and Credit: Ultimate Guide to Bottom Navigation on Android
You can use BottomNavigationView from android support library.
Use the following dependency-
implementation 'com.android.support:design:26.1.0'
And use following in the xml file for bottom navigation bar-
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />
Note - For the magnifying behaviour to work, you need to have more than 3 items in your BottomNavigationView.
I'm experimenting for the first time with Android's Navigation Drawer. I think it is a very elegant way to provide an application menu. However, showing my prototype to some friends, it seems that it is not quit intuitive to search for a menu i) on the top left corner respectively ii) on the left side of the screen.
To provide a "user hint" for case i), I added a custom image by creating an ActionBarDrawerToggle. This results in following design of the title bar (the little arrow is the cutom image, while the red star is the application icon):
Now while developping, I thought this is quite obvious, but apparantly I'm wrong :). So as a second idea, to support a user to find option ii) described below, I tried to figure out how to add a further image at a specific place, which I want to explain with following image:
Don't look at the design itself in the first place, but following: the image must be placed outside of the "view bounds" (when the navigation menu is hidden), and also exceed the navigation panel itself on the right side (always). Is this in any way possible without customize the entire navigation panel? I really wonder why I can't find much about this idea, since I think it is a very nice option to provide for the user (as long as the arrow don't disturbs the application usage)
Although I haven't actually tested it with Android's Navigation Drawer,
did you try putting an imageview in your activity's layout? The image would be placed in the middle vertically and on parent left horizontally. I believe this would work (i.e. the image will get pushed when you open the drawer. As an improvement you could also change the image itself in the drawer's callbacks, so that you have an arrow pointing right when the drawer is closed and an arrow pointing left when the drawer is open.
Hope it helps.
I have a project where the designs require a sliding drawer that comes from the bottom and has essentially three states.
fully collapsed (just the handle at the bottom
half mast (drawer opens from bottom but only halfway up the screen
full mast (drawer opens from bottom and takes up the whole screen minus a top margin of lets say 80dp
I am developing for android 4.0 and higher and obviously sliding drawer is deprecated. But the Navigation drawer only supports left and right (which i already have in use)
So i am wondering if anyone knows a tutorial or even a custom component someone has written that meets the above functionality requirements
In my experience, you probably have to create something yourself, but since you're developing for api lvl 14, check out ObjectAnimator. It allows you to move Views around and still use them (by that I mean that it's the original view that has been moved and not a copy of it)
This will probably be the easiest way.
FYI, using the Navigation Drawer, you can't open the drawer halfway, or you should programmatically invoke touch events...
I think this is what you are looking for.
I have found this library best so far for sliding up menus in Android.
https://github.com/umano/AndroidSlidingUpPanel
You can specify what screen area slide up menu or view will use.
Accept & vote up my answer if it is what you are looking for.
I'm using the slide menu library and setting the menu offset from a xml.
setBehindOffsetRes(R.dimen.slidingmenu_offset);
when I click the menu item I use
menu.toggle(true);
which moves the content to left with menu behind it. My scenario is when I click the menu item, the content has to move all the way to right and then should bring the content in like the normal way so that the user dont get to see the UI change. I used
setBehindOffsetRes(R.dimen.slidingmenu_fullscreen);
showMenu(true);
where R.dimen.slidingmenu_fullscreen = 0dp. The menu goes to full screen behind the content, but the content doesn't moves to the right. Thanks in advance!
Edit 1: This is similar to Xoom application... Sample "Slide Sample"
I would recommend using ActionBarSherlock. Use this tutorial for sliding menu, It is much easier to use, and you will find much more help with it. It is also more compatible with different screen sizes, and more Android versions.
Finally I figured it myself.
menu.mViewAbove.scrollTo(menu.mViewAbove.getScrollX()-200,0);
moved the content to right. But now got into another problem. which I have descibed here->
https://stackoverflow.com/questions/19714871/sliding-menu-move-content-to-right
I'm trying to write a simple wikipedia app for Android 2.2 which allows users to search and view articles.
When a user is viewing an article, I'd like there to be a fixed position search bar that remains fixed at the top of the screen, despite the vertical scroll position, as in this picture:
http://img839.imageshack.us/img839/9159/wikidroid01.png
How can I implement that search bar? Is it a view I stick in my layout? I've already read about Search Dialog boxes in this android tutorial (http://developer.android.com/guide/topics/search/search-dialog.html)... but it's my understanding that the search dialog box search bar can only show if it is focused (when onSearchRequested() is run), right?
Thanks for the help!
You can do it by taking relative layout of fixed height. In that relative layout add the elements in order that you have shown in picture like
1) Imageview with wrap_content height & width.
2) Take Editext with fixed height & width also set Hint for that EditText="Search WikiPedia".
Put this layout as first element in your main layout so that it will be always at top if vertical scroll is there it will not scroll that search bar.
You can use fragments. They allow you to have 2 (or more) views that are controlled separately. Read more here.
Fragments are new to Android 3.0 however there is a compatibility pack that allows you to use them as early as Android 1.6.