Bottom navigation bar to magnify selected item - android

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.

Related

How can I create this custom Bottom Navigation on Android

I am trying to create this custom Bottom Navigation. The design is really good but I do not know how to code such a Navigation.
As you can see, the middle item is the profile pic of the user and the navigation buttons have that custom yellow rounded rectangular as a current page indicator. Any idea how to implement this?
Thank you!
It is done by using library for material design. There are some sites that provides the this type of views you can modified it in some restricted mode.
The sites you can prefer:
Click here to visit the site
The below site also helps you..
bottomAppBar
Ui Design For Bottom Naviagtion

Navigation Drawer Toggle Icon without toolbar

So I'm basically a total beginner in things of app programming.
I started with the "Navigation Drawer Activity" from Android studio and my problem is, I want the nav drawer toggle icon (top left corner) and the "3 dotted icon" (top right corner), but I don't want it in a toolbar.
My question is, should I remove the toolbar and keep the Icons (if so, how could I do that) or should I make the toolbar fullscreen (don't know how to remove the appname)?
Or is there any better way? Like starting from scratch and placing the icons where I want?
Thanks in advance!
What you see as "nav drawer toggle icon" is actually an ActionBarDrawerToggle object and as its name suggests it can only reside in a Toolbar.
The "3 dotted icon" is the toolbar's menu button. You can create a new button with the same icon and use it to popup a menu but it's not that simple.
Remember that the Toolbar is a container and you can customize it the way you want, so my advice is to use it because the other option is a lot harder.
You can set:
in xml
android:elevation="0dp"
or
app:elevation="0dp"
or bycode
getActionBar().setElevation(0);
to remove any elevation of the toolbar.
A few years ago I did something similar to what I think your wanting to do. I made my app so that I had a navigation drawer and settings icon but styled it so that there was no actual visible bar. This gave the app a bit so generic feel and more of a modern look. Also made the drawer and settings menu feel more integrated with the app as a whole. Unfortunately this is a bit of an involved task. For one this in a way, in the sense that they are a "guideline" and that this goes against the idea of making the flow and feel of the app to be what the user is expecting in the traditional sense, goes against the Google Material Guidlines. And two the activity templates are good for learning and generic apps. If your trying to make something that customized is generally going to require you to create everything from scratch. Three, I find I have slight of trouble with the navigation drawer template the Android Studio provides. I'll use it to play around with ideas or to get a feel of how I want my app but if I'm ready to start coding my "production level" app I then start a new project with no activity and make everything myself. Now...
It sounds like what you want is a navigation drawer, which requires a toolbar, but don't want your app name to display. The three simplest solution here would be to go to the strings.xml and in there is a line like so.
<string name:"app_name">YourAppName</string>
Clear that line. (This may cause issues I haven't treated recently and am unable to atm)
There will still be a visible bar across the top though. So if that is not the desired effect, it would be simpler to create a new project with either a black activity or no activity. Google search Android how to create styles and themes and then Google search android navigation drawer with kotlin. Look for a tutorial that shows how to make a navigation drawer from either a blank activity or no activity. Then you will have to create your own style that either doesn't have a color or set the background transparency, of the appbar which is inside/apart of the toolbar, to 100%. I can't remember which because it's been a long time.
I hope this helps.
P.S. Thanks for this question it gives me a great idea for a blog post on my website "How to create a Navigation Drawer with no visible app bar in Kotlin". Once I get it made I'll add a link and can maybe edit my answer with some code detailing the style and theme modifications.

Integrating Bottom Navigation with 5 Menu Items

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.

Adding a custom image onto a Navigation Drawer's center

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.

sliding drawer options android

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.

Categories

Resources