Our designer gave me this sketch of a bottom navigation bar.
The circle below the first item indicates that it is selected. How should one implement this highlighting mechanism? Is it possible to use selectors for this purpose?
I would suggest having a drawable for the selected state and the non selected state where the selected state contains the dot. Then just change the source image when selected.
Related
I need to implement a custom bottomnavigation like in the image. My peculiar issue is that when a menu item from the bottomNav is clicked the bottomnav has to reposition the text above and add an image of a dot below it like as shown in the image.
This means that small solutions to selected state like using a custom selector cannot solve this.
Is there a way to inflate a selected layout to show how the bottomNav should look when selected? What methods or other ways do you suggest I tackle this issue?
Try This Git library It's not 100% same as want, but good
https://github.com/iammert/ReadableBottomBar
Ah! Totally forgot to answer this after I solved it.
I was initially showing an Icon and label combination in the bottomnavigation. I was looking for a way to hide the icon on click and show a dot on the bottom which was the wrong way to go and would be complex.
I ended up adding the icon and label as a group drawable vector instead of individually. So for each bottomnavigation option, I had a drawable selector xml with state for selected and unselected.
I have to create a navigation drawer with a custom menu item.
I know I can create a ListView with custom item layout or use third-party libs etc., but I feel that would be an overkill for this little modification, because the 'default' working method is almost perfect for me.
I have to draw a little rectangle with different color to every menu item.
Can I achieve this with default components somehow?
Finally I've successfully solved the problem by using Mike Penz's MaterialDrawer library with custom drawer item and custom item layout.
I have start and end date time fields that look like in picture below. Blue color shows active selection - if we select right then blue color goes to right and white color appears on the left and vice versa.
Hardest part is to create that arrow style in the middle. What should i use because buttons are rectangles and I don't know how it could be done.
It's easy. Just use ninepatch.
You can start there:
http://radleymarx.com/blog/simple-guide-to-9-patch/
you need a custom image according to what you ask, maybe extend ToggleButton for that but basically what you want is the same component when pressing on two different places on the same component will dispatch different events.
I would for example extend Linear layout, make it vertical layout, put two clickable textView\buttons with 9 patch images as background ,like suggested before, one for the white part and the other for the blue part. and replace the background image for any event u like.
you can also create a StateListDrawable with actions for selected and deselected and set the state of each drawable upon the right click
Instead of continuing the search on how to do this I thought I would pose the question here and see if I had any luck. I am working on an Android app that uses a navigation drawer and I want a custom color when the user touches one of the items in the drawer (not the default light blue). I have three XML files, one for shape/color when not pressed, one for when pressed, and a selector. All of these work great and when a touch on an item in the navigation drawer takes place it shows red like I want. But when the navigation drawer is slid out again the selected item once again shows the default color of light blue. Does anyone know how to keep this custom color selection persistent?
Thank you very much. I certainly appreciate any help!
I want to change the menu item background beacuse I use black icons, but on some phones the default color of background is black or other dark color. I tried this solution and it's worked but there was a little problen with it:
I have ten items and that's why I have a "More" item to show other options, but if I choose the More item (which is got the custom background) and after that I press back button, the item will be in the default state, default colors. What is the solution? Thanks!
The style attribute for the menu background is android:panelFullBackground. It's not hackish like the other solution, so it's not as buggy.
Despite what the documentation says, it needs to be a resource (e.g. #android:color/black or #drawable/my_drawable), it will crash if you use a color value directly.
try to use android own menu icon like as setIcon(android.R.drawable.ic_menu_search)